我有以下代码:
$randomNameCV = substr(md5(uniqid(rand())), 0, 10).date('YmdHi').".pdf";
$storeCV = $request->cv->store('storage/cvs','public');
允许我上传文件,但是当我使用这些方法指定文件名时无法上传:
$storeCV = $request->cv->storeAs(
'storage/cvs', $randomNameCV
);
$storeCV = Storage::putFileAs(
'storage/cvs', $request->file('cv'), $randomNameCV, 'public'
);
答案 0 :(得分:0)
像这样 - 记住extesion:
Storage::putFileAs('photos', new File('/path/to/photo'), 'photo.jpg');
答案 1 :(得分:0)
这里" avatar"是表单的字段名称 -
// name of the file
$randomNameCV = substr(md5(uniqid(rand())), 0, 10).date('YmdHi').".pdf";
// path and file name -- here public is folder name and randomNamecv is file
$path = 'public/'.$randomNameCV;
$request->file('avatar')->store($path);