示例#1
0
 public function processRequest()
 {
     // Ignore other requests except POST.
     if ($_SERVER['REQUEST_METHOD'] !== 'POST' || empty($_POST[PostFields::packageGuid])) {
         return;
     }
     if (UploadHandler::$_processed) {
         return;
     }
     UploadHandler::$_processed = true;
     if (array_key_exists('HTTP_X_PREPROCESS_REQUIRED', $_SERVER) && $_SERVER['HTTP_X_PREPROCESS_REQUIRED'] == 'true') {
         $files = $this->getRequestFiles($_POST);
     } else {
         $files =& $_FILES;
     }
     $uploadCache = new UploadCache($this->_cacheRoot);
     $uploadSession = new UploadSession($uploadCache, $_POST, $files, $_SERVER);
     if (!empty($this->_allFilesUploadedCallback)) {
         $uploadSession->setAllFilesUploadedCallback($this->_allFilesUploadedCallback);
     }
     if (!empty($this->_fileUploadedCallback)) {
         $uploadSession->setFileUploadedCallback($this->_fileUploadedCallback);
     }
     $uploadSession->processRequest();
     $this->removeExpiredSessions($uploadCache);
     // Flash requires non-empty response
     if (!headers_sent() && array_key_exists('HTTP_USER_AGENT', $_SERVER) && $_SERVER['HTTP_USER_AGENT'] === 'Shockwave Flash') {
         echo '0';
     }
 }