MediaWiki  1.23.2
UploadFromFile.php
Go to the documentation of this file.
1 <?php
30 class UploadFromFile extends UploadBase {
31 
35  protected $mUpload = null;
36 
40  function initializeFromRequest( &$request ) {
41  $upload = $request->getUpload( 'wpUploadFile' );
42  $desiredDestName = $request->getText( 'wpDestFile' );
43  if ( !$desiredDestName ) {
44  $desiredDestName = $upload->getName();
45  }
46 
47  $this->initialize( $desiredDestName, $upload );
48  }
49 
55  function initialize( $name, $webRequestUpload ) {
56  $this->mUpload = $webRequestUpload;
57  $this->initializePathInfo( $name,
58  $this->mUpload->getTempName(), $this->mUpload->getSize() );
59  }
60 
65  static function isValidRequest( $request ) {
66  # Allow all requests, even if no file is present, so that an error
67  # because a post_max_size or upload_max_filesize overflow
68  return true;
69  }
70 
74  public function getSourceType() {
75  return 'file';
76  }
77 
81  public function verifyUpload() {
82  # Check for a post_max_size or upload_max_size overflow, so that a
83  # proper error can be shown to the user
84  if ( is_null( $this->mTempPath ) || $this->isEmptyFile() ) {
85  if ( $this->mUpload->isIniSizeOverflow() ) {
86  return array(
87  'status' => UploadBase::FILE_TOO_LARGE,
88  'max' => min(
89  self::getMaxUploadSize( $this->getSourceType() ),
90  wfShorthandToInteger( ini_get( 'upload_max_filesize' ) ),
91  wfShorthandToInteger( ini_get( 'post_max_size' ) )
92  ),
93  );
94  }
95  }
96 
97  return parent::verifyUpload();
98  }
99 }
UploadBase
Definition: UploadBase.php:38
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
UploadBase\FILE_TOO_LARGE
const FILE_TOO_LARGE
Definition: UploadBase.php:62
UploadFromFile\$mUpload
WebRequestUpload $mUpload
Definition: UploadFromFile.php:34
UploadFromFile\initializeFromRequest
initializeFromRequest(&$request)
Definition: UploadFromFile.php:39
wfShorthandToInteger
wfShorthandToInteger( $string='')
Converts shorthand byte notation to integer form.
Definition: GlobalFunctions.php:3889
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
WebRequestUpload
Object to access the $_FILES array.
Definition: WebRequest.php:1159
UploadFromFile\initialize
initialize( $name, $webRequestUpload)
Initialize from a filename and a WebRequestUpload.
Definition: UploadFromFile.php:54
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:336
UploadBase\isEmptyFile
isEmptyFile()
Return true if the file is empty.
Definition: UploadBase.php:229
$upload
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead where the first element is the message key and the remaining elements are used as parameters to the message based on mime etc Preferred in most cases over UploadVerification object $upload
Definition: hooks.txt:2573
UploadBase\initializePathInfo
initializePathInfo( $name, $tempPath, $fileSize, $removeTempFile=false)
Initialize the path information.
Definition: UploadBase.php:202
UploadFromFile\isValidRequest
static isValidRequest( $request)
Definition: UploadFromFile.php:64
UploadFromFile\verifyUpload
verifyUpload()
Definition: UploadFromFile.php:80
UploadFromFile\getSourceType
getSourceType()
Definition: UploadFromFile.php:73
UploadFromFile
Implements regular file uploads.
Definition: UploadFromFile.php:30