I’m trying to create a large, multi-page, PHP web application for work where a client enters information and receives output (think tax software). However, I can’t seem to figure out how to require that a file is uploaded by the client. By files, I mean mostly PDF, txt, JPEG, etc.
There are several file upload fields that must be uploaded for the output to contain all of the necessary information to work, and several other file upload fields that are optional.
I would like to do this in PHP if possible, since as I understand it, Javascript could be turned off and that would stop the validation.
On the PHP file that processes the form you’d want to use something like this:
if (isset ($_FILES['myfile']['tmp_name']) && !empty ($_FILES['myfile']['tmp_name'])) { // process file upload } else { echo 'You must upload a file in the "myfile" field to proceed!'; }This would be in addition to other proper form validation techniques of course.