You are here

function _video_upload_store_file in Video 6

Same name and namespace in other branches
  1. 5 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 480
video.module

Code

function _video_upload_store_file(&$file, &$node) {
  $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 filename = '%s', filepath = '%s', filemime = '%s', filesize = %d WHERE fid = %d", $file->filename, $file->filepath, $file->filemime, $file->filesize, $file->fid);

    // add an entry in the file_revisions table
    db_query("INSERT INTO {video_upload} (vid, nid, fid) VALUES (%d, %d, %d)", $node->vid, $node->nid, $file->fid);

    // update the file db entry

    //db_query("UPDATE {video} SET serialized_data = '%s' WHERE vid = %d", $file->filename, $file->filepath, $file->filemime, $file->filesize, $file->fid);
  }
  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', 'moving file !path to !dest failed', $rep);
  }
}