I have the following code in my form.

function video_subtitles_menu() {
  $items = array();

  $items['video_subtitles_test/upload'] = array(
    'title' => 'Upload Subtitle', //page title
    'description' => 'Uploading subtitle for videos',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('video_upload_subtitles_form'),
    'access callback' => TRUE

  return $items;

function video_upload_subtitles_form($form, &$form_state) {
  $form = array('#attributes' => array('enctype' => 'multipart/form-data'));
  $form['video_name'] = array(
    '#title' => t('Name Of the video'),
    '#type' => 'textfield',

  $form['sub_file'] = array(
    '#type' => 'file',
    '#title' => t('Upload video'),
    '#size' => 48,
    '#description' => t('Pick a video file to upload.'),

  $form['submit_button'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),

  return $form;

function video_upload_subtitles_form_validate() {
  if (!file_check_upload('upload')) {
    form_set_error('upload', 'File missing for upload.');

function video_upload_subtitles_form_submit($form, &$form_state) {
  $video_name = $form_state['values']['video_name'];
  $file = file_save_upload('sub_file', array());
  print "<pre>";print_r($file);// no response here 
  drupal_set_message(t('The form has been submitted.'));

On the submission handler, it only returns the text field. I don't get anything from file upload field, when I use file_save_upload().

This is the response which I get in Firebug. I tried uploading text and Excel files.


What I am trying to do is creating a block where users can upload a file; I then need to get to upload it to a CDN.

  • Have you looked at this comment in the file_save_upload API discussion?
    – msound
    Mar 26, 2014 at 7:16
  • file_save_upload returns An object containing the file information if the upload succeeded, FALSE in the event of an error, or NULL if no file was uploaded.. So if you your result is NULL, it means no file was uploaded, and you should probably look into your server config. If it was FALSE, it means there was an error which you can find in your server logs or Drupal's watchdog (or both). 99 times out of 100 failures are due to permissions problems
    – Clive
    Mar 26, 2014 at 9:05
  • this is the error stored in drupal log Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'H:\xampp\tmp\phpBBFD.tmp' to 'temporary://images.txt' in drupal_move_uploaded_file() (line 1607 of H:\xampp\htdocs\gemkt\trunk\includes\file.inc).
    – Hitesh
    Mar 26, 2014 at 9:46

1 Answer 1


found the solution here.I am not sure what is the core issue but below is the solution

This was the comment in the above link where I found solution.

More than likely eveyone who is having a problem here has been developing on their local computer, then are tryng to migrate their system to a remote server. When you do this, you are probably moving your setting for directory paths along as well.

For example the temp path for your images is probably different than the image temp path on your host system.

I recommend this test in Drupal 6.14. goto /admin/settings/file-system

and look at your temporary directory... if its glaring red, then try renaming it to something like: /tmp. if that does not work, try renaming to just tmp ( no forward slash)

Next step to test this will be to upload an image or file. I tested it by uploading a new logo. But remember, that if you do a FULL DB dump from phpmyadmin from your local computer to the new host, you will probably see this problem again.

For Drupal 7 guys I just went to admin/config/media/file-system , so basically find out where the file system is in your config area and I change the '/tmp' to 'tmp'.

After changing it was able to print the file object :)

stdClass Object ( [uid] => 1 [status] => 0 [filename] => 3-26-2014 12-15-54 PM.png [uri] => temporary://3-26-2014 12-15-54 PM.png [filemime] => image/png [filesize] => 30536 [source] => private_file [destination] => temporary://3-26-2014 12-15-54 PM.png [timestamp] => 1395828492 [type] => image [field_replacement] => stdClass Object ( [uid] => 1 [status] => 0 [filename] => 3-26-2014 12-15-54 PM.png [uri] => temporary://3-26-2014 12-15-54 PM.png [filemime] => image/png [filesize] => 30536 [source] => private_file [destination] => temporary://3-26-2014 12-15-54 PM.png [timestamp] => 1395828492 [type] => image ) [fid] => 3102 ) 

Hope it help someone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.