Mohamed Hassan Mohamed Hassan - 7 months ago 13
PHP Question

how to check if the file field is empty?

I am having a hard time using

$_FILES


I want to check if it's empty or not and if it's not empty then it shouldn't try and uploading the file. How do I check this?

Answer
if($_FILES["file"]["error"] != 0) {
//stands for any kind of errors happen during the uploading
} 

also there is

if($_FILES["file"]["error"] == 4) {
//means there is no file uploaded
}