2

I'm uploading files and by default uploaded filename are set to hashName(). 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();
...
1
  • use $file->move('location',$file->getClientOriginalName()); to save file with custom name or maybe use store function. Commented May 2, 2018 at 2:03

1 Answer 1

3

You can use storeAs() and pass the filename in the 2nd argument

$file = $value->storeAs('public/fca_files', 'Your filename');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.