我正在上传文件,默认情况下上传的文件名设置为 hashName()
。如何将其设置为自定义?
$uploadfiles = $request->file('file');
foreach ($uploadfiles as $key => $value) {
$file = $value->store('public/fca_files');
//Something like $value->store('public/fca_files','May 2, 2018 Report.xlsx');
$file_name_before = $value->getClientOriginalName();
$file_ext = $value->getClientOriginalExtension();
$file_name_after = $value->hashName();
$file_size = $value->getClientSize();
...
最佳答案
您可以使用 storeAs() 并在第二个参数中传递文件名
$file = $value->storeAs('public/fca_files', 'Your filename');
关于php - Laravel:使用 store() 上传时更改文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50126180/