Skip to content

Commit

Permalink
[HttpFoundation] UploadedFile error message
Browse files Browse the repository at this point in the history
  • Loading branch information
bamarni committed Jun 6, 2013
1 parent ea913e0 commit 7ccfe65
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Symfony/Component/HttpFoundation/File/UploadedFile.php
Expand Up @@ -252,7 +252,7 @@ public function move($directory, $name = null)
return $target;
}

throw new FileException($this->getErrorMessage($this->getError()));
throw new FileException($this->getErrorMessage());
}

/**
Expand Down Expand Up @@ -281,11 +281,9 @@ public static function getMaxFilesize()
/**
* Returns an informative upload error message.
*
* @param int $code The error code returned by an upload attempt
*
* @return string The error message regarding the specified error code
*/
private function getErrorMessage($errorCode)
public function getErrorMessage()
{
static $errors = array(
UPLOAD_ERR_INI_SIZE => 'The file "%s" exceeds your upload_max_filesize ini directive (limit is %d kb).',
Expand All @@ -297,6 +295,7 @@ private function getErrorMessage($errorCode)
UPLOAD_ERR_EXTENSION => 'File upload was stopped by a php extension.',
);

$errorCode = $this->error;
$maxFilesize = $errorCode === UPLOAD_ERR_INI_SIZE ? self::getMaxFilesize() / 1024 : 0;
$message = isset($errors[$errorCode]) ? $errors[$errorCode] : 'The file "%s" was not uploaded due to an unknown error.';

Expand Down

0 comments on commit 7ccfe65

Please sign in to comment.