0

If i do the following with file example.jpg the storage file is getting a random name. How can i give it the example.jpg name?

Storage::disk('local')->put('test', $request->file('file') )

This works, but how can i specify a disk?

    $file = request()->file('files');
    $file->storeAs('test',$request->file('files')->getClientOriginalName());

enter image description here

1 Answer 1

1

From the docs,

If you would not like a file name to be automatically assigned to your stored file, you may use the storeAs method, which receives the path, the file name, and the (optional) disk as its arguments:

$file->storeAs('test', $request->file('files')->getClientOriginalName(), 'local');
Sign up to request clarification or add additional context in comments.

6 Comments

error, Exception Impossible to create the root directory "/home/vagrant/Code/xxx/storage/app/test/xxxx.jpg".
does the storage directory has write permission?
i deleted the previous test folder, now the following is created, test/example.jpg/i6fRmKhvhIfuLuBBmXvUq32Xuu8fIIbmwYoywkrX.jpeg , so same problem as mentioned...
sorry, it is storeAs please try again
the disk is passed as an third argument to the method
|

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.