Laravel version update
Laravel version update
This commit is contained in:
@@ -24,41 +24,10 @@ use Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser;
|
||||
*/
|
||||
class UploadedFile extends File
|
||||
{
|
||||
/**
|
||||
* Whether the test mode is activated.
|
||||
*
|
||||
* Local files are used in test mode hence the code should not enforce HTTP uploads.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $test = false;
|
||||
|
||||
/**
|
||||
* The original name of the uploaded file.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $originalName;
|
||||
|
||||
/**
|
||||
* The mime type provided by the uploader.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $mimeType;
|
||||
|
||||
/**
|
||||
* The file size provided by the uploader.
|
||||
*
|
||||
* @var int|null
|
||||
*/
|
||||
private $size;
|
||||
|
||||
/**
|
||||
* The UPLOAD_ERR_XXX constant provided by the uploader.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $error;
|
||||
|
||||
/**
|
||||
@@ -76,11 +45,12 @@ class UploadedFile extends File
|
||||
* Calling any other method on an non-valid instance will cause an unpredictable result.
|
||||
*
|
||||
* @param string $path The full temporary path to the file
|
||||
* @param string $originalName The original file name
|
||||
* @param string $originalName The original file name of the uploaded file
|
||||
* @param string|null $mimeType The type of the file as provided by PHP; null defaults to application/octet-stream
|
||||
* @param int|null $size The file size
|
||||
* @param int|null $size The file size provided by the uploader
|
||||
* @param int|null $error The error constant of the upload (one of PHP's UPLOAD_ERR_XXX constants); null defaults to UPLOAD_ERR_OK
|
||||
* @param 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
|
||||
* @throws FileNotFoundException If the file does not exist
|
||||
@@ -198,7 +168,7 @@ class UploadedFile extends File
|
||||
*/
|
||||
public function isValid()
|
||||
{
|
||||
$isOk = $this->error === UPLOAD_ERR_OK;
|
||||
$isOk = UPLOAD_ERR_OK === $this->error;
|
||||
|
||||
return $this->test ? $isOk : $isOk && is_uploaded_file($this->getPathname());
|
||||
}
|
||||
@@ -222,9 +192,11 @@ class UploadedFile extends File
|
||||
|
||||
$target = $this->getTargetFile($directory, $name);
|
||||
|
||||
if (!@move_uploaded_file($this->getPathname(), $target)) {
|
||||
$error = error_get_last();
|
||||
throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $target, strip_tags($error['message'])));
|
||||
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
|
||||
$moved = move_uploaded_file($this->getPathname(), $target);
|
||||
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());
|
||||
@@ -250,17 +222,20 @@ class UploadedFile extends File
|
||||
|
||||
$max = ltrim($iniMax, '+');
|
||||
if (0 === strpos($max, '0x')) {
|
||||
$max = intval($max, 16);
|
||||
$max = \intval($max, 16);
|
||||
} elseif (0 === strpos($max, '0')) {
|
||||
$max = intval($max, 8);
|
||||
$max = \intval($max, 8);
|
||||
} else {
|
||||
$max = (int) $max;
|
||||
}
|
||||
|
||||
switch (substr($iniMax, -1)) {
|
||||
case 't': $max *= 1024;
|
||||
// no break
|
||||
case 'g': $max *= 1024;
|
||||
// no break
|
||||
case 'm': $max *= 1024;
|
||||
// no break
|
||||
case 'k': $max *= 1024;
|
||||
}
|
||||
|
||||
@@ -285,7 +260,7 @@ class UploadedFile extends File
|
||||
);
|
||||
|
||||
$errorCode = $this->error;
|
||||
$maxFilesize = $errorCode === UPLOAD_ERR_INI_SIZE ? self::getMaxFilesize() / 1024 : 0;
|
||||
$maxFilesize = UPLOAD_ERR_INI_SIZE === $errorCode ? self::getMaxFilesize() / 1024 : 0;
|
||||
$message = isset($errors[$errorCode]) ? $errors[$errorCode] : 'The file "%s" was not uploaded due to an unknown error.';
|
||||
|
||||
return sprintf($message, $this->getClientOriginalName(), $maxFilesize);
|
||||
|
Reference in New Issue
Block a user