Forum

Thread tagged as: Question, Problem, Docs

Add Asset Without Renaming File

When adding an asset to a bucket (via the assets menu and not a template) the asset's filename gets automatically re-written. For example My_File.zip might get uploaded as myfile.zip.

How can one retain the original file name My_File.zip on uploading. I'm happy for new upload to replace files with the same name.

Many thanks

Regards James

James Ng

James Ng 0 points

  • 1 year ago
Robert Ketter

Robert Ketter 97 points
Registered Developer

James, if you don't want the file name re-written then you need to use lowercase, no spaces or underscores. The names are lowercase and all punctuation removed for database.

It's also not possible to overwrite existing because perch does a file_exists() check and continues to add random numbers till the file doesn't exist, then saves the image. So uploading the exact file (3) times will give it (3) different file names.

James Ng

James Ng 0 points

Hi Robert

I now understand that there's not a way to disable this feature via a configuration option, however can I comment out the file_exists check to prevent is appending random number to all file uploads?

Regards James

Robert Ketter

Robert Ketter 97 points
Registered Developer

It's not all files, just previously existing names, and if you modify core code you will no longer receive perch support.

Best to just follow the guidelines I posted previously.