Accepts the information of the uploaded file as provided by the PHP global $_FILES.
The file object is only created when the uploaded file is valid (i.e. when the isValid() method returns true). Otherwise the only methods that could be called on an UploadedFile instance are:
Calling any other method on an non-valid instance will cause an unpredictable result.
@api
string $path The full temporary path to the file:
string $originalName The original file name:
string $mimeType The type of the file as provided by PHP:
integer $size The file size:
integer $error The error constant of the upload (one of PHP's UPLOAD_ERR_XXX constants):
Boolean $test Whether the test mode is active:
FileException If file_uploads is disabled
FileNotFoundException If the file does not exist
Overrides File::__construct
public function __construct($path, $originalName, $mimeType = null, $size = null, $error = null, $test = false) {
if (!ini_get('file_uploads')) {
throw new FileException(sprintf('Unable to create UploadedFile because "file_uploads" is disabled in your php.ini file (%s)', get_cfg_var('cfg_file_path')));
}
$this->originalName = basename($originalName);
$this->mimeType = $mimeType ?: 'application/octet-stream';
$this->size = $size;
$this->error = $error ?: UPLOAD_ERR_OK;
$this->test = (bool) $test;
parent::__construct($path, UPLOAD_ERR_OK === $this->error);
}