Johnny2 Posted March 25, 2013 Report Share Posted March 25, 2013 I have a form with an input field of type="file" name="img1" id="img1". When the form is submitted, I would like to make sure the user selected a file before my script continues. I've tried: if(!isset($_POST['img1'])){ $message="An image file was not selected."; } ...but that isn't working. What am I missing? Quote Link to comment Share on other sites More sharing options...
Moloney Posted March 26, 2013 Report Share Posted March 26, 2013 I have a form with an input field of type="file" name="img1" id="img1". When the form is submitted, I would like to make sure the user selected a file before my script continues. I've tried: if(!isset($_POST['img1'])){ $message="An image file was not selected."; } ...but that isn't working. What am I missing? did you echo the $message? echo $message; ??? Quote Link to comment Share on other sites More sharing options...
Johnny2 Posted March 27, 2013 Author Report Share Posted March 27, 2013 I ended up figuring it out. This works: if($_FILES['img1']['tmp_name'] == ""){} Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.