Skip to content

Commit 7ccfe65

Browse files
committed
[HttpFoundation] UploadedFile error message
1 parent ea913e0 commit 7ccfe65

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/Symfony/Component/HttpFoundation/File/UploadedFile.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public function move($directory, $name = null)
252252
return $target;
253253
}
254254

255-
throw new FileException($this->getErrorMessage($this->getError()));
255+
throw new FileException($this->getErrorMessage());
256256
}
257257

258258
/**
@@ -281,11 +281,9 @@ public static function getMaxFilesize()
281281
/**
282282
* Returns an informative upload error message.
283283
*
284-
* @param int $code The error code returned by an upload attempt
285-
*
286284
* @return string The error message regarding the specified error code
287285
*/
288-
private function getErrorMessage($errorCode)
286+
public function getErrorMessage()
289287
{
290288
static $errors = array(
291289
UPLOAD_ERR_INI_SIZE => 'The file "%s" exceeds your upload_max_filesize ini directive (limit is %d kb).',
@@ -297,6 +295,7 @@ private function getErrorMessage($errorCode)
297295
UPLOAD_ERR_EXTENSION => 'File upload was stopped by a php extension.',
298296
);
299297

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

0 commit comments

Comments
 (0)