function upload($method) { $zoom =& zmgFactory::getEvents()->fire('ongetcore'); zmgimport('org.zoomfactory.lib.helpers.zmgFileHelper'); zmgimport('org.zoomfactory.lib.mime.zmgMimeHelper'); if ($method == "jupload") { echo "JUpload!!!"; } else { $file = zmgGetParam($_FILES, 'Filedata'); $filename = $zoom->checkDuplicate(zmgFileHelper::makeSafe(urldecode($file['name']))); $ext = zmgFileHelper::getExt($filename); $mime = zmgMimeHelper::getMime($file['tmp_name'], $file['type'], $ext); if (zmgFileHelper::tooBig($file['tmp_name'])) { header('HTTP/1.0 415 Unsupported Media Type'); die('Error. File too big!'); } if (!zmgMimeHelper::acceptableFormat($mime, true)) { header('HTTP/1.0 415 Unsupported Media Type'); die('Error. Unsupported Media Type!'); } //try to move the file to a proper location: $dest = ZMG_ABS_PATH . DS . "etc" . DS . "cache" . DS . $filename; if (zmgFileHelper::exists($dest)) { header('HTTP/1.0 409 Conflict'); die('Error. File already exists'); } if (!zmgFileHelper::upload($file['tmp_name'], $dest)) { header('HTTP/1.0 400 Bad Request'); die('Error. Unable to upload file'); } // store the filename into the session (the data is sent to the backend // after the file has been uploaded). $session =& zmgFactory::getSession(); $session->update('uploadtool.fancyfiles', $filename, ZMG_DATATYPE_ARRAY); $session->store(); } }
function setMimeType($mime = null) { if (!$this->filename) { zmgError::throwError('zmgMedium: medium data not loaded yet'); } if ($mime === null) { $path = $this->getAbsPath(); zmgimport('org.zoomfactory.lib.helpers.zmgFileHelper'); zmgimport('org.zoomfactory.lib.mime.zmgMimeHelper'); $mime = zmgMimeHelper::getMime($path, null, $this->getExtension()); } $this->_mime_type = $mime; }