php - Laravel: Change filename when uploading using store()


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();



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

$file = $value->storeAs('public/fca_files', 'Your filename');

People are also looking for solutions to the problem: php - PayPal Chained payment using dynamic variables


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.