How to check if a file is selected

I have a file $fileImage = $_FILES['fileCatImg'];, everything works when I try to download it, but how to check if the file is selected first? if (isset($fileImage))and if (empty($fileImage))do not work. One of them always returns true value, but another always returns false value.

+3
source share
2 answers

Check file size:

if($_FILES['fileCatImg']['size'] > 0) { ... }
+4
source

The file was $_FILES['fileCatImg']['error'] == UPLOAD_ERR_NO_FILEnot uploaded, but it is only useful for determining the corresponding error message. See “Error Messages” for other values ​​that $_FILES['fileCatImg']['error']may be accepted when something goes wrong during file download.

+1
source

All Articles