Custom file name while keeping extension

Viewed 4097

Following this part of the docs:

https://laravel.com/docs/5.3/filesystem#file-uploads

I'm trying to store a file (an image) and specify a custom file name, but I don't want to change the extension.

If I do:

$request->file('avatar')->storeAs('avatars', 'custom_file_name');

The file will save as custom_file_name (with no extension), rather than custom_file_name.png).

How can I specify a custom file name while keeping the original file extension?

3 Answers
Related