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


  • edited 1:51AM
    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:
  • edited 1:51AM
    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 1:51AM
    The not being able to set the "overwrite" value appears to be a bug which I just pushed a fix for:

    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.