Updated Symfony HttpFoundation to 2.1.6.

This commit is contained in:
Taylor Otwell
2013-01-06 13:58:32 -06:00
parent f754e1fa55
commit cb567c5e4d
55 changed files with 1758 additions and 805 deletions

View File

@@ -17,7 +17,7 @@ use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
/**
* A file uploaded through a form.
*
* @author Bernhard Schussek <bernhard.schussek@symfony.com>
* @author Bernhard Schussek <bschussek@gmail.com>
* @author Florian Eckerstorfer <florian@eckerstorfer.org>
* @author Fabien Potencier <fabien@symfony.com>
*
@@ -94,7 +94,7 @@ class UploadedFile extends File
throw new FileException(sprintf('Unable to create UploadedFile because "file_uploads" is disabled in your php.ini file (%s)', get_cfg_var('cfg_file_path')));
}
$this->originalName = basename($originalName);
$this->originalName = $this->getName($originalName);
$this->mimeType = $mimeType ?: 'application/octet-stream';
$this->size = $size;
$this->error = $error ?: UPLOAD_ERR_OK;
@@ -166,7 +166,7 @@ class UploadedFile extends File
/**
* Returns whether the file was uploaded successfully.
*
* @return Boolean True if no error occurred during uploading
* @return Boolean True if no error occurred during uploading
*
* @api
*/
@@ -189,8 +189,21 @@ class UploadedFile extends File
*/
public function move($directory, $name = null)
{
if ($this->isValid() && ($this->test || is_uploaded_file($this->getPathname()))) {
return parent::move($directory, $name);
if ($this->isValid()) {
if ($this->test) {
return parent::move($directory, $name);
} elseif (is_uploaded_file($this->getPathname())) {
$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'])));
}
@chmod($target, 0666 & ~umask());
return $target;
}
}
throw new FileException(sprintf('The file "%s" has not been uploaded via Http', $this->getPathname()));
@@ -199,9 +212,9 @@ class UploadedFile extends File
/**
* Returns the maximum size of an uploaded file as configured in php.ini
*
* @return type The maximum size of an uploaded file in bytes
* @return int The maximum size of an uploaded file in bytes
*/
static public function getMaxFilesize()
public static function getMaxFilesize()
{
$max = trim(ini_get('upload_max_filesize'));