MediaWiki REL1_39
WebRequestUpload Class Reference

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

Inheritance diagram for WebRequestUpload:
Collaboration diagram for 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 33 of file WebRequestUpload.php.

Constructor & Destructor Documentation

◆ __construct()

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 49 of file WebRequestUpload.php.

References $request.

Member Function Documentation

◆ exists()

WebRequestUpload::exists ( )

Return whether a file with this name was uploaded.

Returns
bool

Definition at line 62 of file WebRequestUpload.php.

References $doesExist.

Referenced by getError(), getName(), getSize(), getTempName(), and getType().

◆ getError()

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 137 of file WebRequestUpload.php.

References exists().

Referenced by isIniSizeOverflow().

◆ getName()

WebRequestUpload::getName ( )

Return the original filename of the uploaded file.

Returns
string|null Filename or null if non-existent

Definition at line 71 of file WebRequestUpload.php.

References exists(), and wfDebug().

◆ getSize()

WebRequestUpload::getSize ( )

Return the file size of the uploaded file.

Returns
int File size or zero if non-existent

Definition at line 93 of file WebRequestUpload.php.

References exists().

◆ getTempName()

WebRequestUpload::getTempName ( )

Return the path to the temporary file.

Returns
string|null Path or null if non-existent

Definition at line 107 of file WebRequestUpload.php.

References exists().

◆ getType()

WebRequestUpload::getType ( )

Return the client specified content type.

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

Definition at line 122 of file WebRequestUpload.php.

References exists().

◆ isIniSizeOverflow()

WebRequestUpload::isIniSizeOverflow ( )

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

Returns
bool

Definition at line 152 of file WebRequestUpload.php.

References getError(), and wfShorthandToInteger().

Member Data Documentation

◆ $doesExist

bool WebRequestUpload::$doesExist
protected

Definition at line 39 of file WebRequestUpload.php.

Referenced by exists().

◆ $fileInfo

array null WebRequestUpload::$fileInfo
protected

Definition at line 41 of file WebRequestUpload.php.

◆ $request

WebRequest WebRequestUpload::$request
protected

Definition at line 37 of file WebRequestUpload.php.

Referenced by FauxRequestUpload\__construct(), and __construct().

◆ REQUIRED_FILEINFO_KEYS

const 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 35 of file WebRequestUpload.php.

Referenced by FauxRequest\setUpload().


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