rj28kl Posted February 11, 2009 Share Posted February 11, 2009 Hi, I have a beginner question for PHP and maybe you hand help me easily. I have a contact form where a user should select a file to upload. I have insert this in the form with: <tr> <td>Please attach here your <br>1-Hour-Energy-Audit Excel file:</td> <td><input name="Anhang" size="20" type="file"></td> </tr> <tr> When the form is send, I check allready the fields email address and name with: if($_REQUEST['Send']) { if(empty($_REQUEST['Name']) || empty($_REQUEST['Email'])) { echo"Please <a href=\"javascript:history.back();\">go back</a> to the contact form to fill out all fields. Thank you"; } I had tried to check the attachment field with: if($_REQUEST['Send']) { if(empty($_REQUEST['Name']) || empty($_REQUEST['Email']) || empty($_REQUEST['Anhang'])) { echo"Please <a href=\"javascript:history.back();\">go back</a> to the contact form to fill out all fields. Thank you"; } but that did not work out. I can select a file (path), but I got still the message to fill out all fields. How can I check if a path is selected (or something is in the field) when the user clicks on the send button? Is there an easy solution for a beginner in PHP? Just to have this form work? Link to comment https://forums.phpfreaks.com/topic/144831-check-if-a-file-is-selected-contact-form/ Share on other sites More sharing options...
The Little Guy Posted February 11, 2009 Share Posted February 11, 2009 First don't use $_REQUEST it is deprecated, either use $_GET or $_POST Second, I f you want to check if a file exists do something like this: empty($_FILES['Anhang']['name']) Link to comment https://forums.phpfreaks.com/topic/144831-check-if-a-file-is-selected-contact-form/#findComment-760009 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.