How are you determining the myfilename? You could use UUIID hash or let Laravel name it or add a timestamp.
Mar 10, 2018
3
Level 1
Rename file if exists
Hi, i use Storage::putFileAs($folder, $file, 'myfilename') for storing files with a custom name.
But if "myfilename" already exists it will be replaced with the new file, there are some options or built-in tricks for adding a number at end of the file name if it already exists?
Or I need to use a custom code?
Thanks
Level 53
Yes, you can simply check if the file exists with file_exists().
2 likes
Please or to participate in this conversation.