MediaWiki master
MediaWiki\Request\WebRequestUpload Class Reference

Object to access the $_FILES array. More...

Inherited by MediaWiki\Request\FauxRequestUpload.

Collaboration diagram for MediaWiki\Request\WebRequestUpload:

Public Member Functions

 __construct ( $request, $key)
 Constructor.
 
 exists ()
 Return whether a file with this name was uploaded.
 
 getError ()
 Return the upload error.
 
 getName ()
 Return the original filename of the uploaded file.
 
 getSize ()
 Return the file size of the uploaded file.
 
 getTempName ()
 Return the path to the temporary file.
 
 getType ()
 Return the client specified content type.
 
 isIniSizeOverflow ()
 Returns whether this upload failed because of overflow of a maximum set in php.ini.
 

Public Attributes

const REQUIRED_FILEINFO_KEYS = [ 'name', 'size', 'tmp_name', 'type', 'error', ]
 All keys a fileinfo has to specific to work with this class.
 

Protected Attributes

bool $doesExist
 
array null $fileInfo
 
WebRequest $request
 

Detailed Description

Object to access the $_FILES array.

Definition at line 36 of file WebRequestUpload.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Request\WebRequestUpload::__construct ( $request,
$key )

Constructor.

Should only be called by WebRequest

Parameters
WebRequest$requestThe associated request
string$keyKey in $_FILES array (name of form field)

Definition at line 52 of file WebRequestUpload.php.

References MediaWiki\Request\WebRequestUpload\$request.

Member Function Documentation

◆ exists()

◆ getError()

MediaWiki\Request\WebRequestUpload::getError ( )

Return the upload error.

See link for explanation https://www.php.net/manual/en/features.file-upload.errors.php

Returns
int One of the UPLOAD_ constants, 0 if non-existent

Definition at line 140 of file WebRequestUpload.php.

References MediaWiki\Request\WebRequestUpload\exists().

Referenced by MediaWiki\Request\WebRequestUpload\isIniSizeOverflow().

◆ getName()

MediaWiki\Request\WebRequestUpload::getName ( )

Return the original filename of the uploaded file.

Returns
string|null Filename or null if non-existent

Definition at line 74 of file WebRequestUpload.php.

References MediaWiki\Request\WebRequestUpload\exists(), MediaWiki\MediaWikiServices\getInstance(), and wfDebug().

◆ getSize()

MediaWiki\Request\WebRequestUpload::getSize ( )

Return the file size of the uploaded file.

Returns
int File size or zero if non-existent

Definition at line 96 of file WebRequestUpload.php.

References MediaWiki\Request\WebRequestUpload\exists().

◆ getTempName()

MediaWiki\Request\WebRequestUpload::getTempName ( )

Return the path to the temporary file.

Returns
string|null Path or null if non-existent

Definition at line 110 of file WebRequestUpload.php.

References MediaWiki\Request\WebRequestUpload\exists().

◆ getType()

MediaWiki\Request\WebRequestUpload::getType ( )

Return the client specified content type.

Returns
string|null Type or null if non-existent
Since
1.35

Definition at line 125 of file WebRequestUpload.php.

References MediaWiki\Request\WebRequestUpload\exists().

◆ isIniSizeOverflow()

MediaWiki\Request\WebRequestUpload::isIniSizeOverflow ( )

Returns whether this upload failed because of overflow of a maximum set in php.ini.

Returns
bool

Definition at line 155 of file WebRequestUpload.php.

References MediaWiki\Request\WebRequestUpload\getError(), and wfShorthandToInteger().

Member Data Documentation

◆ $doesExist

bool MediaWiki\Request\WebRequestUpload::$doesExist
protected

Definition at line 42 of file WebRequestUpload.php.

Referenced by MediaWiki\Request\WebRequestUpload\exists().

◆ $fileInfo

array null MediaWiki\Request\WebRequestUpload::$fileInfo
protected

Definition at line 44 of file WebRequestUpload.php.

◆ $request

WebRequest MediaWiki\Request\WebRequestUpload::$request
protected

◆ REQUIRED_FILEINFO_KEYS

const MediaWiki\Request\WebRequestUpload::REQUIRED_FILEINFO_KEYS = [ 'name', 'size', 'tmp_name', 'type', 'error', ]

All keys a fileinfo has to specific to work with this class.

Definition at line 38 of file WebRequestUpload.php.

Referenced by MediaWiki\Request\FauxRequest\setUpload().


The documentation for this class was generated from the following file: