Here’s how to attach multiple files to node field programatically using entity metadata wrapper:

// Create managed File object and associate with Image field.
$file = (object) array(
'uid' => 1,
'uri' => $filepath,
'filemime' => file_get_mimetype($filepath),
'status' => FILE_STATUS_PERMANENT,
);

// We save the file to the root of the files directory.
$file = file_copy($file, 'public://');
$productWrapper->field_image[] = ['fid'=>$file->fid,'display'=>true];

Dejar respuesta

Please enter your comment!
Please enter your name here