Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Specifically name file when uploading
  • Hi All, We've seen the ability to randomise the uploaded file name etc, but i can't see a way of passing through a specific file name for it to use, can anyone point me in the right direction for this one? Matt
  • There is no configuration for this, as it is not known how many files will be uploaded, and in which sequence the user will do that. The Upload class has to be generic enough to deal with this. To deal with details on the specific file level, the best thing you can do is define a callback event, check the file information in the data passed, and update it accordingly. You can either use the 'before' callback, which is called just before saving the uploaded file, to change the destination filename, or the 'after' callback to rename the uploaded file after it has been saved. If your callback isn't that complicated, you can opt to use a closure for this. Note that in this case you data will not be validated, so if you use a name of a file that already exists, the file will be overwritten, even if you have configured that you want unique filenames!
  • Thanks for that, i think i've managed to deal with it using a suffix, as it was to do with having images uploaded with similar filenames, but at different sizes, so seems to be working as i need now...

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion