Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony VichUploaderBundle rename file

Hi is there a way to rename uploaded file using VichUploaderBundle? If I upload two image with same name it will remove the old one and it's a problem for me.

I have configuration exactly the same like in the doc

like image 799
H.W. Avatar asked Aug 04 '15 09:08

H.W.


1 Answers

For this kind of issues, the bundle provide "file namers". They are simple services used to name files, in particular to avoid collisions on the filesystem.

You probably want to use the vich_uploader.namer_origname file namer as it will rename your uploaded files using a uniqueid as the prefix of the filename and keeping the original name and extension (a file named foo.jpg will be stored as 50eb3db039715_foo.jpg)

like image 122
K-Phoen Avatar answered Sep 26 '22 15:09

K-Phoen