getCorePath () .'extra/pear.php'; require Instance::singleton ()->getCorePath () .'extra/zip.php'; $itemId = $_GET['itemId']; $table = $_GET['table']; ?> beginTransaction (); if ($fileType == 'application/save' && !($fileType = $archive->getMimeByExtension (array_pop (explode ('.', $file ['name']))))) throw new Exception (__ ('This file type ( [1] ) is not accept by the system!', $fileType)); if (in_array ($fileType, array ('application/x-zip-compressed', 'application/zip'))) $result = zipFile ($itemId, $table, $fileTemp, $fileSize, $fileType); else { if (!$archive->isAcceptable ($fileType, Archive::IMAGE)) throw new Exception (__ ('This file type ( [1] ) is not accept by the system!', $fileType)); $fileId = Database::nextId ('_media', '_id'); $sth = $db->prepare ("INSERT INTO _media (_id, _name, _mimetype, _size, _user) VALUES ('". $fileId ."', '". $fileName ."', '". $fileType ."', '". $fileSize ."', '". User::singleton ()->getId () ."')"); $sth->execute (); $sth = $db->prepare ("INSERT INTO ". $table ." (_item, _media) VALUES ('". $itemId ."', '". $fileId ."')"); $sth->execute (); if (!move_uploaded_file ($fileTemp, $archive->getDataPath () . 'photo_'. str_pad ($fileId, 7, '0', STR_PAD_LEFT))) throw new Exception (__ ('The file can not be copied into folder [ [1] ]!', $archive->getDataPath () ) ); $result = array ($fileId); } $db->commit (); } catch (PDOException $e) { $db->rollBack (); $message->addWarning ($e->getMessage ()); } catch (Exception $e) { $db->rollBack (); $message->addWarning ($e->getMessage ()); } if (sizeof ($result)) { $message->addMessage (__ ('Send photos with success!')); $str = "parent.createThumb ('". implode ("'); parent.createThumb ('", $result) ."');"; } else $message->addWarning (__ ('No photos could be sent!')); $message->save (); ?>