Revision: 22819
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 23, 2010 00:45 by karmacode
Initial Code
$file_field = field_file_save_file($temp, $validators = array(), file_create_path($destination), $account = NULL); if(count($file_field) > 0){ // Create a new file node after saving the file $img_node = new stdClass(); $img_node->title = $file_field['filename']; $img_node->body = ''; $img_node->status = 1; $img_node->type = 'image'; $img_node->created = time(); $img_node->changed = time(); $img_node->uid = 1; $img_node->status = 1; $img_node->active = 1; $img_node->promote = 1; $img_node->field_image = array( array( 'fid' => $file_field['fid'], 'title' => basename($file_field['filename']), 'filename' => $file_field['filename'], 'filepath' => $file_field['filepath'], 'filesize' => $file_field['filesize'], 'mimetype' => $file_field['filemime'], 'description' => basename($file_field['filename']), 'list' => 1, ), ); node_save($img_node);
Initial URL
http://drupal.org/node/330421
Initial Description
Initial Title
Programmatically create a file node from a saved file
Initial Tags
image, file, drupal
Initial Language
PHP