Rename File on Upload
Closed this issue · 2 comments
shawnsandy commented
Thanks for the great work.
Quick question is there any way to rename the file on upload?
thanks
adrianmiu commented
depends on how much of a change you want. there is a callback function you can set to sanitize the file name that you can use to alter the name
see http://www.sirius.ro/php/sirius/upload/upload_options.html at the bottom
I haven't checked but I believe you can even add folders to the name... like so:
$uploadHandler->setSanitizerCallback(function($name){
return date('Y/m/d') . '/' . preg_replace('/[^a-z0-9\.]+/', '-', strtolower($name));
});
You can also change the array that is passed to the upload (ie: $_FILES['uploaded_file']['name']
)
shawnsandy commented
Thanks, I already used the $_FILES['uploaded_file']['name']
option, would be a nice addition to the class. Awesome library!