function UploadedFile::__construct
Same name in this branch
- 11.1.x vendor/guzzlehttp/psr7/src/UploadedFile.php \GuzzleHttp\Psr7\UploadedFile::__construct()
- 11.1.x vendor/symfony/psr-http-message-bridge/Factory/UploadedFile.php \Symfony\Bridge\PsrHttpMessage\Factory\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 of the uploaded file:
string|null $mimeType The type of the file as provided by PHP; null defaults to application/octet-stream:
int|null $error The error constant of the upload (one of PHP's UPLOAD_ERR_XXX constants); null defaults to UPLOAD_ERR_OK:
bool $test Whether the test mode is active: Local files are used in test mode hence the code should not enforce HTTP uploads
Throws
FileException If file_uploads is disabled
FileNotFoundException If the file does not exist
Overrides File::__construct
2 calls to UploadedFile::__construct()
- UploadedFile::__construct in vendor/
symfony/ psr-http-message-bridge/ Factory/ UploadedFile.php - Accepts the information of the uploaded file as provided by the PHP global $_FILES.
- UploadedFile::__construct in vendor/
symfony/ psr-http-message-bridge/ Factory/ UploadedFile.php - Accepts the information of the uploaded file as provided by the PHP global $_FILES.
1 method overrides UploadedFile::__construct()
- UploadedFile::__construct in vendor/
symfony/ psr-http-message-bridge/ Factory/ UploadedFile.php - Accepts the information of the uploaded file as provided by the PHP global $_FILES.
File
-
vendor/
symfony/ http-foundation/ File/ UploadedFile.php, line 63
Class
- UploadedFile
- A file uploaded through a form.
Namespace
Symfony\Component\HttpFoundation\FileCode
public function __construct(string $path, string $originalName, ?string $mimeType = null, ?int $error = null, bool $test = false) {
$this->originalName = $this->getName($originalName);
$this->originalPath = strtr($originalName, '\\', '/');
$this->mimeType = $mimeType ?: 'application/octet-stream';
$this->error = $error ?: \UPLOAD_ERR_OK;
parent::__construct($path, \UPLOAD_ERR_OK === $this->error);
}