You are here

public function UploadedFile::__construct in Zircon Profile 8

Same name in this branch
  1. 8 vendor/zendframework/zend-diactoros/src/UploadedFile.php \Zend\Diactoros\UploadedFile::__construct()
  2. 8 vendor/symfony/http-foundation/File/UploadedFile.php \Symfony\Component\HttpFoundation\File\UploadedFile::__construct()
  3. 8 vendor/symfony/psr-http-message-bridge/Tests/Fixtures/UploadedFile.php \Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\UploadedFile::__construct()
Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-foundation/File/UploadedFile.php \Symfony\Component\HttpFoundation\File\UploadedFile::__construct()

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:

  • getClientOriginalName,
  • getClientMimeType,
  • isValid,
  • getError.

Calling any other method on an non-valid instance will cause an unpredictable result.

Parameters

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:

int $size The file size:

int $error The error constant of the upload (one of PHP's UPLOAD_ERR_XXX constants):

bool $test Whether the test mode is active:

Throws

FileException If file_uploads is disabled

FileNotFoundException If the file does not exist

Overrides File::__construct

File

vendor/symfony/http-foundation/File/UploadedFile.php, line 88

Class

UploadedFile
A file uploaded through a form.

Namespace

Symfony\Component\HttpFoundation\File

Code

public function __construct($path, $originalName, $mimeType = null, $size = null, $error = null, $test = false) {
  $this->originalName = $this
    ->getName($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);
}