pcman Posted December 3, 2007 Share Posted December 3, 2007 i have this form: php: <?php if(isset($_POST['send'])) { if($_FILES['pic']['name'] != "") { echo "this will be show all the time=["; } else { echo "no file uploaded"; } } else { echo ' <form action="lala.php" method="post" enctype="multipart/form-data"> <input type="file" name="benzona" /> <input type="submit" name="send"> <form> '; } ?> if i dos'nt upload a file the if is still print "this will be show all the time=["... what can i do to solve this problam...? thy Quote Link to comment Share on other sites More sharing options...
Caesar Posted December 3, 2007 Share Posted December 3, 2007 One approach... <?php if(file_exists($path_to_file.$file)) { echo'File was uploaded successfully'; } ?> Quote Link to comment Share on other sites More sharing options...
mr_mind Posted December 3, 2007 Share Posted December 3, 2007 Try this. tell me if it works. <?php if($_POST['send'] && !(isset($message) || isset($error)) { if($_FILES['pic']['name'] != "") { if($_FILES['pic']['error']==0) { $message = 'File sent'; } else { $error = 'Error: ' . $_FILES['pic']['error'] . '. Please notify the site admin.'; } } else { $error = 'You must submit a file'; } } elseif($_POST['send'] && (isset($message) || isset($error))) { if(isset($message)) { print $message; } else { print $error; print '<form action=lala.php method=post enctype=multipart/form-data>'; print '<label for=pic>Picture File: </label><input type=file name=pic id=pic value="' . $_POST['pic'] . '" /><br />'; print '<input type=submit name=send value=Upload>'; print '<form>'; } } elseif(!$_POST['send']) { print '<form action=lala.php method=post enctype=multipart/form-data>'; print '<label for=pic>Picture File: </label><input type=file name=pic id=pic /><br />'; print '<input type=submit name=send value=Upload>'; print '<form>'; } else { print 'An unknown error has occured. Please notify the site admin.'; } ?> Quote Link to comment Share on other sites More sharing options...
pcman Posted December 4, 2007 Author Share Posted December 4, 2007 the problam is solved Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted December 4, 2007 Share Posted December 4, 2007 Then hit the button ( 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.