/** * Initialize from a filename and a WebRequestUpload * @param $name * @param $webRequestUpload */ function initialize($name, $webRequestUpload) { $this->mUpload = $webRequestUpload; $this->initializePathInfo($name, $this->mUpload->getTempName(), $this->mUpload->getSize()); }
/** * Return the size of the upload, or 0. * * @deprecated since 1.17 * @param $key String: * @return integer */ public function getFileSize($key) { wfDeprecated(__METHOD__, '1.17'); $file = new WebRequestUpload($this, $key); return $file->getSize(); }
/** * Return the size of the upload, or 0. * * @deprecated * @param $key String: * @return integer */ public function getFileSize($key) { $file = new WebRequestUpload($this, $key); return $file->getSize(); }
function initLogo() { $this->fileExtensions = array('gif', 'jpg', 'jpeg', 'png'); $request = $this->getRequest(); if (!$request->wasPosted()) { # GET requests just give the main form; no data except wpDestfile. return; } $this->gift_id = $request->getInt('gift_id'); $this->mIgnoreWarning = $request->getCheck('wpIgnoreWarning'); $this->mReUpload = $request->getCheck('wpReUpload'); $this->mUpload = $request->getCheck('wpUpload'); $this->mUploadDescription = $request->getText('wpUploadDescription'); $this->mUploadCopyStatus = $request->getText('wpUploadCopyStatus'); $this->mUploadSource = $request->getText('wpUploadSource'); $this->mWatchthis = $request->getBool('wpWatchthis'); wfDebug(__METHOD__ . ": watchthis is: '{$this->mWatchthis}'\n"); $this->mAction = $request->getVal('action'); $this->mSessionKey = $request->getInt('wpSessionKey'); if (!empty($this->mSessionKey) && isset($_SESSION['wsUploadData'][$this->mSessionKey])) { /** * Confirming a temporarily stashed upload. * We don't want path names to be forged, so we keep * them in the session on the server and just give * an opaque key to the user agent. */ $data = $_SESSION['wsUploadData'][$this->mSessionKey]; $this->mUploadTempName = $data['mUploadTempName']; $this->mUploadSize = $data['mUploadSize']; $this->mOname = $data['mOname']; $this->mStashed = true; } else { /** * Check for a newly uploaded file. */ $this->mUploadTempName = $request->getFileTempName('wpUploadFile'); $file = new WebRequestUpload($request, 'wpUploadFile'); $this->mUploadSize = $file->getSize(); $this->mOname = $request->getFileName('wpUploadFile'); $this->mSessionKey = false; $this->mStashed = false; } }
/** * uploadFile -- save file when is in proper format, do resize and * other stuffs * * @param Request $request -- WebRequest instance * @param String $input -- name of file input in form * @param $errorMsg -- optional string containing details on what went wrong if there is an UPLOAD_ERR_EXTENSION. * * @return Integer -- error code of operation */ public function uploadFile($request, $input = AVATAR_UPLOAD_FIELD, &$errorMsg = '') { global $wgTmpDirectory; wfProfileIn(__METHOD__); $this->__setLogType(); if (!isset($wgTmpDirectory) || !is_dir($wgTmpDirectory)) { $wgTmpDirectory = '/tmp'; } // Wikia::log( __METHOD__, "tmp", "Temp directory set to {$wgTmpDirectory}" ); $errorNo = $request->getUploadError($input); if ($errorNo != UPLOAD_ERR_OK) { // Wikia::log( __METHOD__, "error", "Upload error {$errorNo}" ); wfProfileOut(__METHOD__); return $errorNo; } $file = new WebRequestUpload($request, $input); $iFileSize = $file->getSize(); if (empty($iFileSize)) { /** * file size = 0 */ // Wikia::log( __METHOD__, 'empty', "Empty file {$input} reported size {$iFileSize}" ); wfProfileOut(__METHOD__); return UPLOAD_ERR_NO_FILE; } $sTmpFile = $wgTmpDirectory . '/' . substr(sha1(uniqid($this->mUser->getID())), 0, 16); // Wikia::log( __METHOD__, 'tmp', "Temp file set to {$sTmpFile}" ); $sTmp = $request->getFileTempname($input); // Wikia::log( __METHOD__, 'path', "Path to uploaded file is {$sTmp}" ); if (move_uploaded_file($sTmp, $sTmpFile)) { $errorNo = $this->postProcessImageInternal($sTmpFile, $errorNo, $errorMsg); } else { // Wikia::log( __METHOD__, 'move', sprintf('Cannot move uploaded file from %s to %s', $sTmp, $sTmpFile )); $errorNo = UPLOAD_ERR_CANT_WRITE; } wfProfileOut(__METHOD__); return $errorNo; }
/** * uploadFile -- save file when is in proper format, do resize and * other stuffs * * @param WebRequest $request -- WebRequest instance * @param String $input -- name of file input in form * @param $errorMsg -- optional string containing details on what went wrong if there is an UPLOAD_ERR_EXTENSION. * * @return Integer -- error code of operation */ public function uploadFile($request, $input = AVATAR_UPLOAD_FIELD, &$errorMsg = '') { // macbre: avatars operations are disabled during maintenance global $wgAvatarsMaintenance; if (!empty($wgAvatarsMaintenance)) { return UPLOAD_ERR_NO_TMP_DIR; } wfProfileIn(__METHOD__); $this->__setLogType(); $errorNo = $request->getUploadError($input); if ($errorNo != UPLOAD_ERR_OK) { wfProfileOut(__METHOD__); return $errorNo; } $file = new WebRequestUpload($request, $input); $iFileSize = $file->getSize(); if (empty($iFileSize)) { /** * file size = 0 */ wfProfileOut(__METHOD__); return UPLOAD_ERR_NO_FILE; } $sTmpFile = $this->getTempFile(); $sTmp = $request->getFileTempname($input); if (move_uploaded_file($sTmp, $sTmpFile)) { $errorNo = $this->postProcessImageInternal($sTmpFile, $errorNo, $errorMsg); } else { $errorNo = UPLOAD_ERR_CANT_WRITE; } wfProfileOut(__METHOD__); return $errorNo; }
/** * Initialize the uploaded file from PHP data * @param $request WebRequest */ protected function initializeUpload($request) { $file = new WebRequestUpload($request, 'wpUploadFile'); $this->mTempPath = $file->getTempName(); $this->mFileSize = $file->getSize(); $this->mSrcName = $file->getName(); }