Mercurial > hg > isophonics-drupal-site
diff vendor/zendframework/zend-diactoros/src/UploadedFile.php @ 12:7a779792577d
Update Drupal core to v8.4.5 (via Composer)
author | Chris Cannam |
---|---|
date | Fri, 23 Feb 2018 15:52:07 +0000 |
parents | 4c8ae668cc8c |
children | c2387f117808 |
line wrap: on
line diff
--- a/vendor/zendframework/zend-diactoros/src/UploadedFile.php Fri Feb 23 15:51:18 2018 +0000 +++ b/vendor/zendframework/zend-diactoros/src/UploadedFile.php Fri Feb 23 15:52:07 2018 +0000 @@ -1,9 +1,7 @@ <?php /** - * Zend Framework (http://framework.zend.com/) - * - * @see http://github.com/zendframework/zend-diactoros for the canonical source repository - * @copyright Copyright (c) 2015-2016 Zend Technologies USA Inc. (http://www.zend.com) + * @see https://github.com/zendframework/zend-diactoros for the canonical source repository + * @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (http://www.zend.com) * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License */ @@ -16,13 +14,25 @@ class UploadedFile implements UploadedFileInterface { + const ERROR_MESSAGES = [ + UPLOAD_ERR_OK => 'There is no error, the file uploaded with success', + UPLOAD_ERR_INI_SIZE => 'The uploaded file exceeds the upload_max_filesize directive in php.ini', + UPLOAD_ERR_FORM_SIZE => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was ' + . 'specified in the HTML form', + UPLOAD_ERR_PARTIAL => 'The uploaded file was only partially uploaded', + UPLOAD_ERR_NO_FILE => 'No file was uploaded', + UPLOAD_ERR_NO_TMP_DIR => 'Missing a temporary folder', + UPLOAD_ERR_CANT_WRITE => 'Failed to write file to disk', + UPLOAD_ERR_EXTENSION => 'A PHP extension stopped the file upload.', + ]; + /** - * @var string + * @var string|null */ private $clientFilename; /** - * @var string + * @var string|null */ private $clientMediaType; @@ -114,7 +124,10 @@ public function getStream() { if ($this->error !== UPLOAD_ERR_OK) { - throw new RuntimeException('Cannot retrieve stream due to upload error'); + throw new RuntimeException(sprintf( + 'Cannot retrieve stream due to upload error: %s', + self::ERROR_MESSAGES[$this->error] + )); } if ($this->moved) { @@ -147,7 +160,10 @@ } if ($this->error !== UPLOAD_ERR_OK) { - throw new RuntimeException('Cannot retrieve stream due to upload error'); + throw new RuntimeException(sprintf( + 'Cannot retrieve stream due to upload error: %s', + self::ERROR_MESSAGES[$this->error] + )); } if (! is_string($targetPath) || empty($targetPath)) {