Created
October 22, 2012 15:08
-
-
Save harmstyler/3931938 to your computer and use it in GitHub Desktop.
Function for parsing eZ Images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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