php - Laravel: Change filename when uploading using store()
151
I'm uploading files and by default uploaded filename are set tohashName()
. How can I set it to customized?
$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();
...
Answer
Solution:
You can use storeAs() and pass the filename in the 2nd argument