In my form I have 3 input fields for file upload:
<input type=file name="cover_image">
<input type=file name="image1">
<input type=file name="image2">
How can I check if cover_image is empty – no file is put for upload?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can check by using the
sizefield on the$_FILESarray like so:(I also check
errorhere because it may be0if something went wrong (ie. a file was selected, but there’s no data received). I wouldn’t usenamefor this check since that can be overridden).errorwith a value of4isUPLOAD_ERR_NO_FILE, so we can check for that too.