Unable to upload file using Form API
apersaud - January 8, 2009 - 22:49
I created a module for a custom content type, and I have a file upload form element. But, I can't get the file upload form element to save the file. I've read the forums all day and I can't figure out why it keeps failing.
Here is the code in my sikvideo_form(&$node) function:
$form['#attributes']['enctype'] = 'multipart/form-data';
$form['file_upload'] = array(
'#title' => t('Upload video file'),
'#type' => 'file',
'#description' => t('Upload a video'),
);and here is the code in my sikvideo_node_form_submit($form, &$form_state) function:
$validators = array();
$dest = file_directory_path();
$file = file_save_upload('file_upload', $validators, $dest);
if ($file == 0) {
form_set_error('sikvideo', t("Failed to save the file."));
}Any ideas on what the issue could be?

I havent attempted this
I havent attempted this myself, but i did read about this module a while ago. have a read and see if it will help you.
http://drupal.org/project/upapi