@@ -60,10 +60,10 @@ public function __construct($path, $originalName, $mimeType = null, $size = null
60
60
$ this ->originalName = $ this ->getName ($ originalName );
61
61
$ this ->mimeType = $ mimeType ?: 'application/octet-stream ' ;
62
62
$ this ->size = $ size ;
63
- $ this ->error = $ error ?: UPLOAD_ERR_OK ;
63
+ $ this ->error = $ error ?: \ UPLOAD_ERR_OK ;
64
64
$ this ->test = (bool ) $ test ;
65
65
66
- parent ::__construct ($ path , UPLOAD_ERR_OK === $ this ->error );
66
+ parent ::__construct ($ path , \ UPLOAD_ERR_OK === $ this ->error );
67
67
}
68
68
69
69
/**
@@ -89,7 +89,7 @@ public function getClientOriginalName()
89
89
*/
90
90
public function getClientOriginalExtension ()
91
91
{
92
- return pathinfo ($ this ->originalName , PATHINFO_EXTENSION );
92
+ return pathinfo ($ this ->originalName , \ PATHINFO_EXTENSION );
93
93
}
94
94
95
95
/**
@@ -168,7 +168,7 @@ public function getError()
168
168
*/
169
169
public function isValid ()
170
170
{
171
- $ isOk = UPLOAD_ERR_OK === $ this ->error ;
171
+ $ isOk = \ UPLOAD_ERR_OK === $ this ->error ;
172
172
173
173
return $ this ->test ? $ isOk : $ isOk && is_uploaded_file ($ this ->getPathname ());
174
174
}
@@ -217,7 +217,7 @@ public static function getMaxFilesize()
217
217
$ sizePostMax = self ::parseFilesize (ini_get ('post_max_size ' ));
218
218
$ sizeUploadMax = self ::parseFilesize (ini_get ('upload_max_filesize ' ));
219
219
220
- return min ($ sizePostMax ?: PHP_INT_MAX , $ sizeUploadMax ?: PHP_INT_MAX );
220
+ return min ($ sizePostMax ?: \ PHP_INT_MAX , $ sizeUploadMax ?: \ PHP_INT_MAX );
221
221
}
222
222
223
223
/**
@@ -263,17 +263,17 @@ private static function parseFilesize($size)
263
263
public function getErrorMessage ()
264
264
{
265
265
static $ errors = [
266
- UPLOAD_ERR_INI_SIZE => 'The file "%s" exceeds your upload_max_filesize ini directive (limit is %d KiB). ' ,
267
- UPLOAD_ERR_FORM_SIZE => 'The file "%s" exceeds the upload limit defined in your form. ' ,
268
- UPLOAD_ERR_PARTIAL => 'The file "%s" was only partially uploaded. ' ,
269
- UPLOAD_ERR_NO_FILE => 'No file was uploaded. ' ,
270
- UPLOAD_ERR_CANT_WRITE => 'The file "%s" could not be written on disk. ' ,
271
- UPLOAD_ERR_NO_TMP_DIR => 'File could not be uploaded: missing temporary directory. ' ,
272
- UPLOAD_ERR_EXTENSION => 'File upload was stopped by a PHP extension. ' ,
266
+ \ UPLOAD_ERR_INI_SIZE => 'The file "%s" exceeds your upload_max_filesize ini directive (limit is %d KiB). ' ,
267
+ \ UPLOAD_ERR_FORM_SIZE => 'The file "%s" exceeds the upload limit defined in your form. ' ,
268
+ \ UPLOAD_ERR_PARTIAL => 'The file "%s" was only partially uploaded. ' ,
269
+ \ UPLOAD_ERR_NO_FILE => 'No file was uploaded. ' ,
270
+ \ UPLOAD_ERR_CANT_WRITE => 'The file "%s" could not be written on disk. ' ,
271
+ \ UPLOAD_ERR_NO_TMP_DIR => 'File could not be uploaded: missing temporary directory. ' ,
272
+ \ UPLOAD_ERR_EXTENSION => 'File upload was stopped by a PHP extension. ' ,
273
273
];
274
274
275
275
$ errorCode = $ this ->error ;
276
- $ maxFilesize = UPLOAD_ERR_INI_SIZE === $ errorCode ? self ::getMaxFilesize () / 1024 : 0 ;
276
+ $ maxFilesize = \ UPLOAD_ERR_INI_SIZE === $ errorCode ? self ::getMaxFilesize () / 1024 : 0 ;
277
277
$ message = isset ($ errors [$ errorCode ]) ? $ errors [$ errorCode ] : 'The file "%s" was not uploaded due to an unknown error. ' ;
278
278
279
279
return sprintf ($ message , $ this ->getClientOriginalName (), $ maxFilesize );
0 commit comments