#1 2021-12-15 22:50:50


How to customize the upload directory and file renaming?


I need to upload all the files to . /uplods, instead of taking the /YYYY/MM format to create more subdirectories.

How can I customize the renaming rules when uploading files? I want to remove the date from the file name

The original style: … u_e663.jpg
I want to change it to: or




#2 2021-12-16 01:49:36

Only trying to help

Re: How to customize the upload directory and file renaming?

Take a look at admin/include/ in function add_uploaded_file() line 197 and following, starting with the comment
// upload directory hierarchy

However, to get rid of the upload date altogether you would have to not only strip the subdirectories from $upload_dir but also substitute the $date_string in $filename_wo_ext (with what?), and then implement a mechanism to prevent filename clashes, the simple $random_string partial md5sum without the date+time and not in subdirectories will not be sufficient.

Note that path+filename are stored in the database table piwigo_images column `path`, so changing already existing path names will need adaption there as well.

Anyway, I doubt that upload function would be the only place to be adapted, there may be other places that assume the current structure, grep for upload_dir (of the $conf['upload_dir'] setting) and inspect code around, also plugins may be affected and even hardwire things. Be prepared that things may break or not work the way you'd like.

Also note that cramming all files into one directory may significantly slow down things for a huge amount of images, even worse with the thumbnail derivatives that are generated under _data/i/upload/ (however that might be affected by the change) that even multiply the amount of files.

What would that even be good for anyways? It's just the upload date+time you see.

Running Piwigo at



Board footer

Powered by FluxBB

github twitter newsletter Donate © 2002-2022 · Contact