Uploaded file names converted to lowercase but not in database
  • vertmonkee December 2011
    When I upload an image in the CMS it saves the filename to the database using the actual filename but when it actually uploads the image it converts it to all lowercase.

    In my form_fields function in my model I have the following two lines

    $upload_path = assets_server_path('graphics/', 'images');

    $fields['file_name'] = array('type' => 'file', 'upload_path' => $upload_path, 'overwrite' => TRUE);

    How can I ensure that the are both the same?

    Thanks
  • adminadmin December 2011
    Try something like the following to see if it works for you:
    ...
    $upload_path = assets_server_path('graphics/', 'images');
    $fields['file_name'] = array('label' => 'File name');
    $fields['file_name_upload'] = array('label' => '... OR upload a file', 'type' => 'file', 'upload_path' => $upload_path, 'overwrite' => TRUE);
  • toymachiner62toymachiner62 February 20
    I'm experiencing this same issue. I changed my $fields['filename'] var to $fields['filename_upload'] but that didn't do anything different. The name of the file in the db still has an uppercase letter, but the actual file uploaded is all lowercase.

    Is there any solution to this?
  • adminadmin February 20
    There is a property on any model that extends base_module_model called upload_data that you can access in an on_after_post model hook. That information will tell you the actual uploaded file name which you can use to resave it with the proper name. It's not pretty but should hopefully help with your situation. BTW... this will be changed in the next major release.
  • toymachiner62toymachiner62 February 21
    What i've done so far is to just change lines 714 and 715 of fuel/modules/fuel/controllers/module.php from this:

    $posted[$tmp_field_name] = url_title($field_value, 'underscore', TRUE);
    $posted[$field_name] = url_title($field_value, 'underscore', TRUE);


    to this:

    $posted[$tmp_field_name] = url_title($field_value, 'underscore', FALSE);
    $posted[$field_name] = url_title($field_value, 'underscore', FALSE);


    It seems to solve the issue with the filename capitalization. The only issue im having now is that when I have a filename called "Abc_123.jpg", if i use fuel_var(), the filename turns to "Abc 123.jpg".

    Do you know how I can get around this?
  • adminadmin February 23
    Sorry for the delay but I don't have a good answer at the moment... any luck on your end?
  • toymachiner62toymachiner62 February 23
    Nope. This one's got me stumped..

Howdy, Stranger!

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

Sign In Apply for Membership

Categories