I've try create new node by function drupal_execute(), all fine, but now i want also include to this node attachment file, that already in files/ dir.
Now i know how it's do with node_save, but i want use drupal_execute()

// it's creating node with node_save()
$node = new StdClass();
$node->type = 'task_ocr';
$node->title = $xmlEntity[$i]["name"];
$node->uid = $user->uid;
$node->name = $user->name;
$node->status = 1;
$node->field_status[key] = $xmlEntity[$i]->status["value"];
$node->field_priority_0[0]["value"] = $xmlEntity[$i]->priority["value"];
$node->field_arguments[0]["value"] = $xmlEntity[$i]->arguments["value"];
$node->field_stack_size[0]["value"] = $xmlEntity[$i]->stackSize["value"];
$node->field_entity_name[0]["value"] = $xmlEntity[$i]->entrypoint["value"];

$fname = (string)$xmlEntity[$i]->sourceFile["value"];
$tmp = explode("/", $fname);
$fname = $tmp[1];
$fData = array();
$fData = getFcontentByFname($fname, $files);
$file_temp = file_save_data($fData["data"], "files/{$fData["name"]}", FILE_EXISTS_RENAME);

$node->files = array(
	array(
		'fid' => 'upload',
		'title' => basename($file_temp),
		'filename' => basename($file_temp),
		'filepath' => $file_temp,
		'filesize' => filesize($file_temp),
         	'list' => 1, 
		'description' =>  basename($file_temp),
	),
);
node_save($node);

Plz, help me!

Comments

ibragim’s picture

.