MediaWiki  master
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. More...
 
 exists ()
 Return whether a file with this name was uploaded. More...
 
 getError ()
 Return the upload error. More...
 
 getName ()
 Return the original filename of the uploaded file. More...
 
 getSize ()
 Return the file size of the uploaded file. More...
 
 getTempName ()
 Return the path to the temporary file. More...
 
 getType ()
 Return the client specified content type. More...
 
 isIniSizeOverflow ()
 Returns whether this upload failed because of overflow of a maximum set in php.ini. More...
 

Public Attributes

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

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 Sanitizer\decodeCharReferences(), 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: