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.

How to post a file upload from a form?

edited December 2011 in Modules
I have spent hours trying to get this to work but with no luck. Is there a tutorial for a user-form to upload a file somewhere? Unfortunately, this tutorial http://getfuelcms.com/user_guide/modules/tutorial only deals with forms displayed within the CMS.

I build my form using this for the image field:

$upload_path = WEB_ROOT.'uploads/'; $fields['image_upload'] = array('type' => 'file', 'label' => 'Image: ', 'accept' => 'gif|jpg|png|jpeg', 'upload_path' => $upload_path, 'required' => FALSE, 'overwrite' => TRUE);

This works on the form and even puts the browse button.

My database field to store the file name is called "image" and is varchar(255);

When I post the form, I can print_r($_FILES) and see all the meta data for the selected file, however, the file does not get uploaded.

Do I need to load a library or a helper?

Do I need to call a function like do_upload() or _process_uploads() or something else?

Any help is appreciated as I am stuck.

Thanks in advance.

Comments

  • edited 10:16PM
    If this is outside of the Fuel back end you'll need to do some processing of the files to save it.

    Can you paste your controller?

    If you need a head start in the interim, you can see how Fuel handles it in: modules/fuel/controllers/module::create()

    You'll see it runs it's protected _process() method.
Sign In or Register to comment.