File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -282,10 +282,14 @@ public function mimetype()
282
282
*
283
283
* @uses finfo
284
284
* @param string $file The file to check.
285
- * @return string|false Returns the given file's MIME type or FALSE if an error occurred.
285
+ * @return string|null Returns the given file's MIME type or FALSE if an error occurred.
286
286
*/
287
287
public function getMimetypeFor ($ file )
288
288
{
289
+ if (!$ this ->fileExists ($ file )) {
290
+ return null ;
291
+ }
292
+
289
293
$ info = new finfo (FILEINFO_MIME_TYPE );
290
294
291
295
return $ info ->file ($ file );
@@ -380,7 +384,7 @@ public function getFilesize()
380
384
{
381
385
if (!$ this ->filesize ) {
382
386
$ val = $ this ->val ();
383
- if (!$ val || !file_exists ( $ val ) || ! is_readable ($ val )) {
387
+ if (!$ val || !$ this -> fileExists ($ val )) {
384
388
return 0 ;
385
389
} else {
386
390
$ this ->filesize = filesize ($ val );
@@ -428,14 +432,14 @@ public function validateAcceptedMimetypes()
428
432
$ mimetype = $ this ->mimetype ;
429
433
} else {
430
434
$ val = $ this ->val ();
431
- if (!$ val ) {
435
+ if (!$ val || ! $ this -> fileExists ( $ val ) ) {
432
436
return true ;
433
437
}
434
438
$ mimetype = $ this ->getMimetypeFor ($ val );
435
439
}
436
440
$ valid = false ;
437
441
foreach ($ acceptedMimetypes as $ m ) {
438
- if ($ m == $ mimetype ) {
442
+ if ($ m === $ mimetype ) {
439
443
$ valid = true ;
440
444
break ;
441
445
}
You can’t perform that action at this time.
0 commit comments