Core upload handler.

package XenForo_Upload

 Methods

Constructor.

__construct(string $fileName, string $tempFile) 

Parameters

$fileName

string

User-supplied file name

$tempFile

string

Upload temporary file name; this can be an empty string to account for uploads that are too large

Gets the errors for the upload.

getErrors() : array

Returns

array

Gets the user-supplied file name.

getFileName() : string

Returns

string

Gets the value of a specific image info field.

getImageInfoField(string $field) : mixed | false

Parameters

$field

string

Returns

mixedfalseMixed scalar, or false if not an image or invalid field

Gets the path to the temporary file.

getTempFile() : string

Returns

string

Gets the file that was uploaded into the specified form field (via HTTP POST).

getUploadedFile(string $formField, array $source) : \XenForo_Upload

Parameters

$formField

string

Name of the form field

$source

arraynull

Source array ($_FILES by default).

Returns

\XenForo_Upload(or false)

Gets the files that were uploaded into the specified form field (via HTTP POST).

getUploadedFiles(string $formField, array $source) : array

Parameters

$formField

string

Name of the form field

$source

arraynull

Source array ($_FILES by default).

Returns

arrayFormat: [] => XenForo_Upload objects

Returns true if the upload is a valid image.

isImage() : boolean

Returns

boolean

Returns true if the upload is valid.

isValid() : boolean

Returns

boolean

Set the constraints for this upload.

setConstraints(array $constraints) 

Possible keys: * extensions - array of allowed extensions * size - max file size in bytes * width - max image width in pixels * height - max image height in pixels

Parameters

$constraints

array

See above for format.

Checks for errors in the upload.

_checkForErrors() 

Checks the state of the upload to determine if it's a valid image.

_checkImageState() 

 Properties

 

List of allowed attachment extensions.

$_allowedExtensions : array

 

If true, automatically resizes images that are too large.

$_autoResize : boolean

 

List of errors that occured in the upload.

$_errors : array

 

True if errors have been checked.

$_errorsChecked : boolean

 

The extension from the user-supplied file name.

$_extension : string

 

The user-supplied file name of the upload.

$_fileName : string

 

If the upload is an image, information about the image.

$_imageInfo : array | false | null

If null, state is unknown; if false, not an image. Otherwise, array with keys: * from getimagesize() * width/height/type

 

Maximum attachment file size in bytes.

$_maxFileSize : integer

 

Maximum attachment image height in pixels.

$_maxHeight : integer

 

Maximum attachment image width in pixels.

$_maxWidth : integer

 

Full path to the temporary file created by the upload.

$_tempFile : string