Skip to content
Advertisement

Check if specific input file is empty

In my form I have 3 input fields for file upload:

JavaScript

How can I check if cover_image is empty – no file is put for upload?

Advertisement

Answer

You can check by using the size field on the $_FILES array like so:

JavaScript

(I also check error here because it may be 0 if something went wrong. I wouldn’t use name for this check since that can be overridden)

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement