Hi, I am developing a module and currently in my form function I have
function example_module_form{
$form['item_picture'] = array(
'#type' => 'file',
'#title' => t('Upload Picture'),
'#description' => t('Upload a picture of yourself '),
);
}
How would I go about processing this in the function
function example_module_form_submit{
//what do I put here?
}
I would like to upload this file to the drupal set file directory with a subdirectory that will be $user->name . I'd also like to possibly have the name of the file to be fixed. I also need to the location of this file in mysql for easy access.
Any general direction on how to prcoess this upload would be helpful. - Thank you for your time.
Comments
I haven't done this myself,
I haven't done this myself, but suggest you look at
Handling File Uploads
http://drupal.org/node/111782
http://api.drupal.org/api/file/developer/topics/forms_api_reference.html...
I tried to use this method
I tried to use this method but file_check_upload() function seems to not work in drupal 6.x I haven't had success with this method
nm
I think i see my error. I need $form['#attributes'] = array('enctype' => "multipart/form-data"); in my form
the file_check_upload still
the file_check_upload still did not work. But I figured out that I actually needed $form['#validate'][] = 'example_function'; in order to process the file correctly.