Uploaded file names converted to lowercase but not in database

edited December 2011 in Modules
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

Comments

  • edited 4:03AM
    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);
  • 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?
  • edited 4:03AM
    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.
  • 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?
  • edited 4:03AM
    Sorry for the delay but I don't have a good answer at the moment... any luck on your end?
  • Nope. This one's got me stumped..
  • edited 4:03AM
    I'm dealing with this also. Fuel rewrites filenames on upload, and I'm trying to capture the rewritten filename. Using $this->upload_data() in my model (which extends Base_module_model) throws an unknown method exception...
  • edited 4:03AM
    It's actually just $this->upload_data which is an array (not a method)
  • edited 4:03AM
    Thanks - that's the ticket... What woud be helpful for me, as well, is to locate the function that is rewriting filenames so I can use the same function to do some file processing after the file has been written...
  • edited 4:03AM
    it uses the url_title($my_var, 'underline', TRUE).
Sign In or Register to comment.