Note the upgraded forum! If you are experiencing issues logging in, you may need to reset your password which should send an email. If the email doesn't arrive, be sure to check your spam folder just in case.

Upload Multiple Files of Different Types

edited August 2011 in Modules
I have tried to follow the Creating Simple Modules tutorial, but amending it to handle uploading two mp3s and an image. Have got no idea where to start.

Have tried with just a single mp3 file which works (select in form and saves value in database) but then can not access the value; inside of track_model extends data_record, $this->track_path.

Any and all help appreciated

Comments

  • edited 2:20PM
    Is the problem the uploading of multiple files to folders? Or is the problem that you are not able to access the values in the model?

    Also, I'll point out that there is a "editable_asset_filetypes" FUEL configuration value that determines what file types can be uploaded to which folders if you are not familiar with it:
    http://www.getfuelcms.com/user_guide/general/configuration
  • edited 2:20PM
    Sorry, didn't read the documentation properly! Me bad.
    Am handling the files in the on_after_post($values) method then just doing a simple check;
    E.g. if (isset($_FILES['track']) && $_FILES['track']['size'] > 0) { ... }
  • edited August 2011
    In my 'form_fields' method I am declaring a file upload with the configuration of not overwriting;
    $fields['icon']['class'] = 'asset_select icons/tracks'; $upload_path = assets_server_path('tracks/icons', 'media'); $fields['icon'] = array('type' => 'file', 'upload_path' => $upload_path, 'overwrite' => FALSE);
    But when I check my server it appears to retain the original name (even though a file of that name already exists).

    Assuming if it did work OK, how would I access the new name, would it still be though the $values array?
  • edited 2:20PM
    The not being able to set the "overwrite" value appears to be a bug which I just pushed a fix for:
    https://github.com/daylightstudio/FUEL-CMS/commit/8b2999d9453940bd995d895109695a8c6607ad7b

    To access the upload information, there is an "upload_data" array property that you can access in the "on_after_post" hook:
    function on_after_post() { print_r($this->upload_data); }
Sign In or Register to comment.