Represents a file that did not successfully upload.

Errors occur when the client did something wrong. The possible causes are:

  • The client did not upload a file.
  • The client uploaded a partial, incomplete file.
  • The client sent more bytes than either the form or the server allowed.
see which occurs when the server went wrong or the client appears to be circumventing PHP file upload safeguards.
package Haldayne

 Methods

Change the text associated with a PHP upload error code.

changeErrorMessage(integer $code, string $message) 
APIStatic

You may want to localize or otherwise change the generic error associated with one of the upload error codes. You may only change messages for the following upload error codes:

  • UPLOAD_ERR_INI_SIZE (1) : The upload exceeds the upload_max_filesize directive.
  • UPLOAD_ERR_FORM_SIZE (2) : The upload exceeds the MAX_FILE_SIZE directive in the HTML form.
  • UPLOAD_ERR_PARTIAL (3) : The upload was incomplete.
  • UPLOAD_ERR_NO_FILE (4) : No file was uploaded.
api
since 1.0.0

Parameters

$code

integer

The code whose message you want to change.

$message

string

The new message for that code.

Exceptions

\OutOfBoundsException If the given code does not have a message

Return a description of why the error occurred.

getErrorMessage() 
API
see To adjust the message globally.
api
since 1.0.0

Get the HTML variable name.

getHtmlName() : string
APIInherited
api
since 1.0.0

Returns

string

Is the error because the uploaded file was only partially received?

isPartial(integer $received = null) : boolean
API
api
since 1.0.0

Parameters

$received

integer

The number of bytes received.

Returns

boolean

Is the error because the uploaded file was too big?

isTooBig(integer $maximum = null) : boolean
API

An upload may exceed either the upload_max_filesize setting or the MAX_FILE_SIZE input. This method handles both cases and returns true if either of these limits was reached. In such a case, the optional pass-by-reference $maximum will indicate the maximum possible size.

api
since 1.0.0

Parameters

$maximum

integer

The server or form allowed maximum file size, in bytes.

Returns

boolean

Is the error because no file was uploaded?

notUploaded() : boolean
API
api
since 1.0.0

Returns

boolean

 Properties

 

The error code.

$code : integer

Default

 

The HTML name we were given.

$htmlName : string

Default

 

The possible failure codes and an English description.

$messages 

Default

array(UPLOAD_ERR_INI_SIZE => 'The file size exceeds the server-allowed limit.', UPLOAD_ERR_FORM_SIZE => 'The file size exceeds the form-allowed upload limit.', UPLOAD_ERR_PARTIAL => 'The file was only partially uploaded.', UPLOAD_ERR_NO_FILE => 'No file was uploaded.')
Static
 

The size of the file uploaded.

$size : integer

Default