예제 #1
0
 /*
 if ( ! $file_helper->is_zip( $temp_name ) ) {
 	throw new Exception( 'Not A .zip file' );
 }
 */
 $zip_file_name = $temp_image_dir_path . '/images.zip';
 $success = move_uploaded_file($temp_name, $zip_file_name);
 if (!$success) {
     throw new Exception('Upload Failed');
     //die miserably
 }
 $zipper = new PclZip($zip_file_name);
 $zipper->extract($temp_image_dir_path);
 $temp_image_dir_resource = opendir($temp_image_dir_path);
 while (($image_file_name = readdir($temp_image_dir_resource)) !== false) {
     if (!$file_helper->is_jpg($image_file_name)) {
         continue;
     }
     $source = $temp_image_dir_path . '/' . $image_file_name;
     $image_mapper = RequestRegistry::getImageMapper();
     $image = new Image();
     $image->setAlbumId($album->getId());
     $image_mapper->insert($image);
     $target = $photos_dir . $image->getId() . '.jpg';
     $image->setFilename($image->getId() . '.jpg');
     $image_mapper->update($image);
     rename($source, $target);
 }
 //delte our temporary directory
 unlink($zip_file_name);
 rmdir($temp_image_dir_path);