mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-12-16 20:03:47 +09:00
Updates to vendors etc
This commit is contained in:
@@ -31,10 +31,10 @@ use Symfony\Component\Mime\MimeTypes;
|
||||
*/
|
||||
class UploadedFile extends File
|
||||
{
|
||||
private bool $test;
|
||||
private string $originalName;
|
||||
private string $mimeType;
|
||||
private int $error;
|
||||
private string $originalPath;
|
||||
|
||||
/**
|
||||
* Accepts the information of the uploaded file as provided by the PHP global $_FILES.
|
||||
@@ -60,12 +60,17 @@ class UploadedFile extends File
|
||||
* @throws FileException If file_uploads is disabled
|
||||
* @throws FileNotFoundException If the file does not exist
|
||||
*/
|
||||
public function __construct(string $path, string $originalName, ?string $mimeType = null, ?int $error = null, bool $test = false)
|
||||
{
|
||||
public function __construct(
|
||||
string $path,
|
||||
string $originalName,
|
||||
?string $mimeType = null,
|
||||
?int $error = null,
|
||||
private bool $test = false,
|
||||
) {
|
||||
$this->originalName = $this->getName($originalName);
|
||||
$this->originalPath = strtr($originalName, '\\', '/');
|
||||
$this->mimeType = $mimeType ?: 'application/octet-stream';
|
||||
$this->error = $error ?: \UPLOAD_ERR_OK;
|
||||
$this->test = $test;
|
||||
|
||||
parent::__construct($path, \UPLOAD_ERR_OK === $this->error);
|
||||
}
|
||||
@@ -92,6 +97,21 @@ class UploadedFile extends File
|
||||
return pathinfo($this->originalName, \PATHINFO_EXTENSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the original file full path.
|
||||
*
|
||||
* It is extracted from the request from which the file has been uploaded.
|
||||
* This should not be considered as a safe value to use for a file name/path on your servers.
|
||||
*
|
||||
* If this file was uploaded with the "webkitdirectory" upload directive, this will contain
|
||||
* the path of the file relative to the uploaded root directory. Otherwise this will be identical
|
||||
* to getClientOriginalName().
|
||||
*/
|
||||
public function getClientOriginalPath(): string
|
||||
{
|
||||
return $this->originalPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the file mime type.
|
||||
*
|
||||
@@ -174,7 +194,7 @@ class UploadedFile extends File
|
||||
restore_error_handler();
|
||||
}
|
||||
if (!$moved) {
|
||||
throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s).', $this->getPathname(), $target, strip_tags($error)));
|
||||
throw new FileException(\sprintf('Could not move the file "%s" to "%s" (%s).', $this->getPathname(), $target, strip_tags($error)));
|
||||
}
|
||||
|
||||
@chmod($target, 0666 & ~umask());
|
||||
@@ -264,6 +284,6 @@ class UploadedFile extends File
|
||||
$maxFilesize = \UPLOAD_ERR_INI_SIZE === $errorCode ? self::getMaxFilesize() / 1024 : 0;
|
||||
$message = $errors[$errorCode] ?? 'The file "%s" was not uploaded due to an unknown error.';
|
||||
|
||||
return sprintf($message, $this->getClientOriginalName(), $maxFilesize);
|
||||
return \sprintf($message, $this->getClientOriginalName(), $maxFilesize);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user