Custom file name while keeping extension
laravel, laravel-5, laravel-5.3
Solution
You can get extension of uploaded file with:
$extension = $request->photo->extension();
And apply it manually to the stored file name.
The `UploadedFile` class also contains methods for accessing the file's fully-qualified path and its extension. The `extension` method will attempt to guess the file's extension based on its contents.
https://laravel.com/docs/5.4/requests#files
Problem
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?