Uppercase file extension saving as lowercase in database.

edited July 2014 in Modules
If I upload an image from my iPhone in my Fuel module, it has an uppercase extension (photo.JPG). It gets saved as photo.jpg in the database, but the file uploaded is still photo.JPG, so it doesn't display on the website. How can I make the extension lowercase? In form_fields, I have $filename = strtolower(uniqid()); and $fields['picture_upload'] = array('type' => 'file', 'upload_path' => $upload_path, 'filename' => $filename, 'overwrite' => TRUE);

Comments

  • edited 10:00AM
    What version of FUEL are you running?
  • edited 10:00AM
    0.9.2
  • edited July 2014
    That should be fixed in the latest version of FUEL (1.6) and will retain the .JPG.
    Here are some general instructions for upgrading (it may vary though depending on your installation so be sure to save a copy if you need to revert back).
    http://forum.getfuelcms.com/discussion/1515#Item_2
  • edited 10:00AM
    I upgraded to the Fuel CMS master... If I wanted to make the file extension lowercase, how would I go about that?
  • edited 10:00AM
    You could either rename the image before uploading all together, or create an on_after_post model hook to both change the file name on the server and change the file name in database table that it's being saved in. You can access all the uploaded image information with $this->fuel->assets->uploaded_data(); and then do further manipulation with the file name using something like the "rename" php function of the file. To update the database record you could do something roughly like the following (I haven't tested this code):
    function on_after_post($values){ { $uploaded = $this->fuel->assets->uploaded_data(); $upload_path = $uploaded['image']['upload_path']; $new_name = preg_replace('#\.JPG$#', $upload_path); rename($upload_path, $new_name); $record = $this->find_by_key($values['id']); $record->image = strtolower($values['image']; $record->save(); }
  • edited August 2014
    After upgrading to 1.1, one of the users can no longer see entries in the modules (loading icon spins forever). They're using IE11. Have you encountered this problem before?
  • edited 10:00AM
    If you look in the javascript console, there is probably an AJAX request that is returning an error. If so, what does that error message say.
Sign In or Register to comment.