182x Posted July 14, 2007 Share Posted July 14, 2007 Hey guys, I have created an upload file script for a form however if the user does not upload a file I do not want the file upload part of the script to be used. Is there a way to check if the file type on the form is empty? Thanks. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted July 14, 2007 Share Posted July 14, 2007 if (!empty($_FILES))... Quote Link to comment Share on other sites More sharing options...
182x Posted July 14, 2007 Author Share Posted July 14, 2007 hey thanks for the reply im a total newbie does that mean if there is not a file then do whatever? thanks again Quote Link to comment Share on other sites More sharing options...
182x Posted July 14, 2007 Author Share Posted July 14, 2007 I am using the following structure but no matter what I do now it calls the last else and does not upload even if a file has been selected. Have I used the empty function in the wrong way? <?php session_start(); if(strlen($_POST['description']) > 4000) { //error msg } else{ if (!empty($_FILES)) { //upload } else { //don't upload } } ?> Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted July 15, 2007 Share Posted July 15, 2007 nope.. perhaps try referencing the fileupload fieldname if (!empty($_FILES['upfile']['name'])) ... where upfile is the name or id of the file input you used. 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.