function UploadedFile::move
Same name in this branch
- 11.1.x vendor/symfony/psr-http-message-bridge/Factory/UploadedFile.php \Symfony\Bridge\PsrHttpMessage\Factory\UploadedFile::move()
Moves the file to a new location.
Throws
FileException if, for any reason, the file could not have been moved
Overrides File::move
2 calls to UploadedFile::move()
- UploadedFile::move in vendor/
symfony/ psr-http-message-bridge/ Factory/ UploadedFile.php - Moves the file to a new location.
- UploadedFile::move in vendor/
symfony/ psr-http-message-bridge/ Factory/ UploadedFile.php - Moves the file to a new location.
1 method overrides UploadedFile::move()
- UploadedFile::move in vendor/
symfony/ psr-http-message-bridge/ Factory/ UploadedFile.php - Moves the file to a new location.
File
-
vendor/
symfony/ http-foundation/ File/ UploadedFile.php, line 181
Class
- UploadedFile
- A file uploaded through a form.
Namespace
Symfony\Component\HttpFoundation\FileCode
public function move(string $directory, ?string $name = null) : File {
if ($this->isValid()) {
if ($this->test) {
return parent::move($directory, $name);
}
$target = $this->getTargetFile($directory, $name);
set_error_handler(function ($type, $msg) use (&$error) {
$error = $msg;
});
try {
$moved = move_uploaded_file($this->getPathname(), $target);
} finally {
restore_error_handler();
}
if (!$moved) {
throw new FileException(\sprintf('Could not move the file "%s" to "%s" (%s).', $this->getPathname(), $target, strip_tags($error)));
}
@chmod($target, 0666 & ~umask());
return $target;
}
switch ($this->error) {
case \UPLOAD_ERR_INI_SIZE:
throw new IniSizeFileException($this->getErrorMessage());
case \UPLOAD_ERR_FORM_SIZE:
throw new FormSizeFileException($this->getErrorMessage());
case \UPLOAD_ERR_PARTIAL:
throw new PartialFileException($this->getErrorMessage());
case \UPLOAD_ERR_NO_FILE:
throw new NoFileException($this->getErrorMessage());
case \UPLOAD_ERR_CANT_WRITE:
throw new CannotWriteFileException($this->getErrorMessage());
case \UPLOAD_ERR_NO_TMP_DIR:
throw new NoTmpDirFileException($this->getErrorMessage());
case \UPLOAD_ERR_EXTENSION:
throw new ExtensionFileException($this->getErrorMessage());
}
throw new FileException($this->getErrorMessage());
}