Skip to content

Instantly share code, notes, and snippets.

@harmstyler
Created October 22, 2012 15:08
Show Gist options
  • Save harmstyler/3931938 to your computer and use it in GitHub Desktop.
Save harmstyler/3931938 to your computer and use it in GitHub Desktop.
Function for parsing eZ Images
if (isset($_FILES['photos']) && !empty($_FILES['photos']['tmp_name'])) {
foreach ($_FILES['photos']['tmp_name'] as $i=>$tmp) {
if (!$_FILES['photos']['tmp_name'][$i]) {
continue;
}
$fileName = $_FILES['photos']['name'][$i];
$guid = uniqid();
$path = '/tmp/jshwriteupload/' . $guid . '/';
$stored = $path . $fileName;
mkdir($path, 0777, true);
move_uploaded_file($tmp, $stored);
$image = array();
$image['class_identifier']='image';
$image['creator_id'] = $user->attribute('contentobject_id');
$image['parent_node_id'] = $contentObject->attribute('main_node_id');
$image['attributes']['name'] = $fileName;
$image['attributes']['image'] = $fileName;
$image['attributes']['credit'] = handleXmlField('');
$image['attributes']['caption'] = handleXmlField('');
$image['storage_dir'] = $path;
$imageObject = eZContentFunctions::createAndPublishObject($image);
unlink($stored);
rmdir($path);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment