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

lyricnz’s picture

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...

thomasmeadows’s picture

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

thomasmeadows’s picture

I think i see my error. I need $form['#attributes'] = array('enctype' => "multipart/form-data"); in my form

thomasmeadows’s picture

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.