当前位置: 首页>>代码示例>>PHP>>正文


PHP UploadBase::createFromRequest方法代码示例

本文整理汇总了PHP中UploadBase::createFromRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP UploadBase::createFromRequest方法的具体用法?PHP UploadBase::createFromRequest怎么用?PHP UploadBase::createFromRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UploadBase的用法示例。


在下文中一共展示了UploadBase::createFromRequest方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadRequest

 private function loadRequest($request)
 {
     global $wgUser;
     $this->mRequest = $request;
     $this->mAction = $request->getInt(ADD_RESOURCE_ACTION_FIELD);
     switch ($this->mAction) {
         case ADD_RESOURCE_ACTION_UPLOAD:
             $this->mUpload = UploadBase::createFromRequest($request);
             # used by copied processUpload()
             $this->mUploadClicked = true;
             $this->mComment = $request->getVal('wpUploadDescription');
             break;
         case ADD_RESOURCE_ACTION_SUBPAGE:
             $this->mSubpageDest = $request->getVal('wpSubpageDest');
             break;
         case ADD_RESOURCE_ACTION_LINK:
             $this->mLinkUrl = $request->getVal('wpLinkUrl');
             $this->mLinkTitle = $request->getVal('wpLinkTitle');
             $this->mLinkDesc = $request->getVal('wpLinkDesc');
             break;
         default:
             break;
     }
     $this->mTokenOk = $wgUser->matchEditToken($request->getVal('wpEditToken'));
     $this->mCancelUpload = false;
 }
开发者ID:n0g,项目名称:AddResource,代码行数:26,代码来源:SpecialAddResource.php

示例2: loadRequest

 /**
  * Initialize instance variables from request and create an Upload handler
  */
 protected function loadRequest()
 {
     $this->mRequest = $request = $this->getRequest();
     $this->mSourceType = $request->getVal('wpSourceType', 'file');
     $this->mUpload = UploadBase::createFromRequest($request);
     $this->mUploadClicked = $request->wasPosted() && ($request->getCheck('wpUpload') || $request->getCheck('wpUploadIgnoreWarning'));
     // Guess the desired name from the filename if not provided
     $this->mDesiredDestName = $request->getText('wpDestFile');
     if (!$this->mDesiredDestName && $request->getFileName('wpUploadFile') !== null) {
         $this->mDesiredDestName = $request->getFileName('wpUploadFile');
     }
     $this->mLicense = $request->getText('wpLicense');
     $this->mDestWarningAck = $request->getText('wpDestFileWarningAck');
     $this->mIgnoreWarning = $request->getCheck('wpIgnoreWarning') || $request->getCheck('wpUploadIgnoreWarning');
     $this->mWatchthis = $request->getBool('wpWatchthis') && $this->getUser()->isLoggedIn();
     $this->mCopyrightStatus = $request->getText('wpUploadCopyStatus');
     $this->mCopyrightSource = $request->getText('wpUploadSource');
     $this->mForReUpload = $request->getBool('wpForReUpload');
     // updating a file
     $commentDefault = '';
     $commentMsg = wfMessage('upload-default-description')->inContentLanguage();
     if (!$this->mForReUpload && !$commentMsg->isDisabled()) {
         $commentDefault = $commentMsg->plain();
     }
     $this->mComment = $request->getText('wpUploadDescription', $commentDefault);
     $this->mCancelUpload = $request->getCheck('wpCancelUpload') || $request->getCheck('wpReUpload');
     // b/w compat
     // If it was posted check for the token (no remote POST'ing with user credentials)
     $token = $request->getVal('wpEditToken');
     $this->mTokenOk = $this->getUser()->matchEditToken($token);
     $this->uploadFormTextTop = '';
     $this->uploadFormTextAfterSummary = '';
 }
开发者ID:D66Ha,项目名称:mediawiki,代码行数:36,代码来源:SpecialUpload.php

示例3: loadRequest

 /**
  * Initialize instance variables from request and create an Upload handler
  *
  * @param WebRequest $request The request to extract variables from
  */
 protected function loadRequest($request)
 {
     global $wgUser, $wgMaxUploadFiles;
     // let's make the parent happy
     wfSuppressWarnings();
     $_FILES['wpUploadFile'] = $_FILES['wpUploadFile0'];
     wfRestoreWarnings();
     // Guess the desired name from the filename if not provided
     $this->mDesiredDestNames = array();
     $this->mUploads = array();
     // deal with session keys, if we have some pick the first one, for now
     $vals = $request->getValues();
     $fromsession = false;
     foreach ($vals as $k => $v) {
         if (preg_match("@^wpSessionKey@", $k)) {
             $request->setVal('wpSessionKey', $v);
             $fromsession = true;
             $filenum = preg_replace("@wpSessionKey@", '', $k);
             $request->setVal('wpDestFile', $request->getVal('wpDestFile' . $filenum));
             $up = UploadBase::createFromRequest($request);
             $this->mUploads[] = $up;
             $this->mDesiredDestNames[] = $request->getVal('wpDestFile' . $filenum);
         }
     }
     parent::loadRequest($request);
     $this->mUploadClicked = $request->wasPosted() && ($request->getCheck('wpUpload') || $request->getCheck('wpUploadIgnoreWarning'));
     if (!$fromsession) {
         for ($i = 0; $i < $wgMaxUploadFiles; $i++) {
             $this->mDesiredDestNames[$i] = $request->getText('wpDestFile' . $i);
             if (!$this->mDesiredDestNames[$i] && $request->getFileName('wpUploadFile' . $i) !== null) {
                 $this->mDesiredDestNames[$i] = $request->getFileName('wpUploadFile' . $i);
             }
             wfSuppressWarnings();
             $request->setVal('wpUploadFile', $_FILES['wpUploadFile' . $i]);
             wfRestoreWarnings();
             $request->setVal('wpDestFile', $request->getVal('wpDestFile' . $i));
             move_uploaded_file('wpUploadFile' . $i, 'wpUploadFile');
             wfSuppressWarnings();
             $_FILES['wpUploadFile'] = $_FILES['wpUploadFile' . $i];
             wfRestoreWarnings();
             $up = UploadBase::createFromRequest($request);
             if ($up) {
                 $this->mUploads[] = $up;
             }
         }
     }
     $this->mDesiredDestName = $this->mDesiredDestNames[0];
     $this->mUpload = $this->mUploads[0];
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:54,代码来源:MultiUpload.body.php

示例4: loadFile

 function loadFile($type)
 {
     global $wgRequest, $wgUser;
     $ext = $type;
     $file_name = "Drawio_" . $wgRequest->getVal('drawio') . "." . $ext;
     $wgRequest->setVal('wpDestFile', $file_name);
     $wgRequest->setVal('wpIgnoreWarning', '1');
     $wgRequest->setVal('wpDestFileWarningAck', '1');
     $wgRequest->setVal('wpUploadDescription', "");
     $wgRequest->setVal('action', "");
     if ($type == "png") {
         $file_type = "image/png";
         $pngval = $wgRequest->getVal($type);
         $comma_pos = strpos($pngval, ',');
         if ($comma_pos === false) {
             $file_body = stripslashes($pngval);
         } else {
             $file_body = base64_decode(substr($pngval, $comma_pos + 1));
         }
     } else {
         $file_type = "text/xml";
         $file_body = $wgRequest->getVal($type);
     }
     $file_len = strlen($file_body);
     if ($file_len > 0) {
         $_FILES['wpUploadFile']['name'] = $file_name;
         $_FILES['wpUploadFile']['type'] = $file_type;
         $_FILES['wpUploadFile']['error'] = 0;
         $_FILES['wpUploadFile']['size'] = $file_len;
         // $tmp_name = $_SERVER["DOCUMENT_ROOT"] . "tmp/tmp_".rand(0,1000).rand(0,1000).".".$ext;
         $tmp_name = wfTempDir() . "tmp_" . rand(0, 1000) . rand(0, 1000) . "." . $ext;
         $f = fopen($tmp_name, "w");
         fwrite($f, $file_body);
         fclose($f);
         $_FILES['wpUploadFile']['tmp_name'] = $tmp_name;
         // Upload
         $form = UploadBase::createFromRequest($wgRequest, null);
         $outcome = $form->verifyUpload();
         $res = $form->performUpload("", "", true, $wgUser);
         if (file_exists($tmp_name)) {
             unlink($tmp_name);
         }
     }
     // $outcome['request'] = $wgRequest;
     // $outcome['form'] = $form;
     return $outcome;
 }
开发者ID:tosher,项目名称:wiki_drawio,代码行数:47,代码来源:Drawio.body.php

示例5: loadRequest

 /**
  * Initialize instance variables from request and create an Upload handler
  *
  * @param WebRequest $request The request to extract variables from
  */
 protected function loadRequest($request)
 {
     $this->mRequest = $request;
     $this->mSourceType = $request->getVal('wpSourceType', 'file');
     $this->mUpload = UploadBase::createFromRequest($request);
     $this->mUploadClicked = $request->wasPosted() && ($request->getCheck('wpUpload') || $request->getCheck('wpUploadIgnoreWarning'));
     // Guess the desired name from the filename if not provided
     $this->mDesiredDestName = $request->getText('wpDestFile');
     if (!$this->mDesiredDestName) {
         $this->mDesiredDestName = $request->getText('wpUploadFile');
     }
     $this->mComment = $request->getText('wpUploadDescription');
     $this->mLicense = $request->getText('wpLicense');
     $this->mDestWarningAck = $request->getText('wpDestFileWarningAck');
     $this->mIgnoreWarning = $request->getCheck('wpIgnoreWarning') || $request->getCheck('wpUploadIgnoreWarning');
     $this->mWatchthis = $request->getBool('wpWatchthis');
     $this->mCopyrightStatus = $request->getText('wpUploadCopyStatus');
     $this->mCopyrightSource = $request->getText('wpUploadSource');
     $this->mForReUpload = $request->getBool('wpForReUpload');
     // updating a file
     $this->mCancelUpload = $request->getCheck('wpCancelUpload') || $request->getCheck('wpReUpload');
     // b/w compat
     // If it was posted check for the token (no remote POST'ing with user credentials)
     $token = $request->getVal('wpEditToken');
     if ($this->mSourceType == 'file' && $token == null) {
         // Skip token check for file uploads as that can't be faked via JS...
         // Some client-side tools don't expect to need to send wpEditToken
         // with their submissions, as that was new in 1.16.
         $this->mTokenOk = true;
     } else {
         $this->mTokenOk = $this->getUser()->matchEditToken($token);
     }
     $this->mInputID = $request->getText('sfInputID');
     $this->mDelimiter = $request->getText('sfDelimiter');
     $this->uploadFormTextTop = '';
     $this->uploadFormTextAfterSummary = '';
 }
开发者ID:Rikuforever,项目名称:wiki,代码行数:42,代码来源:SF_UploadWindow.php

示例6: upload

 /**
  * Upload passed filename into the wiki as if it were posted by the normal upload form
  * - $name is updated since the upload method may modify the filename used
  */
 function upload($file, &$name, $comment, $text)
 {
     $user = User::newFromName('EmailToWiki');
     $_GET['wpDestFile'] = $name;
     $_GET['wpDestFileWarningAck'] = 1;
     $_FILES['wpUploadFile'] = array('name' => basename($file), 'tmp_name' => $file, 'size' => filesize($file));
     $request = new WebRequest();
     $upload = UploadBase::createFromRequest($request, 'File');
     $upload->verifyUpload();
     $title = $upload->getTitle();
     if (is_object($title)) {
         $status = $upload->performUpload($comment, $text, false, $user);
         $name = $title->getPrefixedText();
     } else {
         return 'File "' . basename($file) . '" could not be uploaded, the file-extension is probably not permitted by the wiki';
     }
     return $status->isGood() ? true : $status->getWikiText();
 }
开发者ID:saper,项目名称:organic-extensions,代码行数:22,代码来源:EmailToWiki.php

示例7: setUploadBase

 public function setUploadBase($object = null)
 {
     if (isset($this->upload_base)) {
         return;
     }
     return $this->upload_base = isset($object) ? $object : UploadBase::createFromRequest($this->request);
 }
开发者ID:akvankorlaar,项目名称:manuscriptdesk,代码行数:7,代码来源:NewManuscriptImageValidator.php


注:本文中的UploadBase::createFromRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。