You are here

function devel_generate_add_upload in Devel 6

1 call to devel_generate_add_upload()
devel_generate_nodeapi in ./


./, line 384


function devel_generate_add_upload(&$node) {
  $source = 'misc/blog.png';
  $size = filesize($source);

  // $after this call, $source contains the new path.
  $file = new stdClass();
  $file->filename = 'blog.png';
  $file->filepath = $source;
  $file->filemime = 'image/png';
  $file->list = variable_get('upload_list_default', TRUE);
  $file->description = 'b log.png was here';
  $file->filesize = $size;
  $file->weight = mt_rand(0, 10);
  $file->new = TRUE;

  // If we made it this far it's safe to record this file in the database.
  db_query("INSERT INTO {files} (uid, filename, filepath, filemime, filesize, status, timestamp) VALUES (%d, '%s', '%s', '%s', %d, %d, %d)", $node->uid, $file->filename, $file->filepath, $file->filemime, $file->filesize, FILE_STATUS_TEMPORARY, time());
  $file->fid = db_last_insert_id('files', 'fid');
  $node->files[$file->fid] = $file;