You are here

function _video_upload_store_file in Video 5

Same name and namespace in other branches
  1. 6 types/video_upload/video_upload.module \_video_upload_store_file()
  2. 6.2 types/video_upload/video_upload.module \_video_upload_store_file()

Move a temp file into the final directory associating it with the node

2 calls to _video_upload_store_file()
_video_upload_insert in types/video_upload/video_upload.module
_video_upload_update in types/video_upload/video_upload.module

File

types/video_upload/video_upload.module, line 483
Enable Uploaded videos support for video module.

Code

function _video_upload_store_file(&$file, &$node) {

  // $file->filename is video_upload_temp.realfile.ext : let's restore original filename
  $file->filename = _video_get_original_filename($file->filename);
  _video_upload_get_path($file, $node);
  if (file_move($file, file_directory_path())) {

    // file moved successfully
    // update the file db entry
    db_query("UPDATE {files} SET nid = %d, filename = '%s', filepath = '%s', filemime = '%s', filesize = %d WHERE fid = %d", $node->nid, $file->filename, $file->filepath, $file->filemime, $file->filesize, $file->fid);

    // add an entry in the file_revisions table
    db_query("INSERT INTO {file_revisions} (fid, vid, list, description) VALUES (%d, %d, %d, '%s')", $file->fid, $node->vid, $file->list, $file->description);
  }
  else {
    drupal_set_message(t('An error occurred during file saving. Your video file has not been stored.'), 'error');
    $rep = array(
      '!path' => $file,
      '!dest' => $dest_path,
    );
    watchdog('video_upload', t('moving file !path to !dest failed', $rep));
  }
}