suttercain Posted September 13, 2007 Share Posted September 13, 2007 Hi guys, I have a form that allows five photo uploads at once. The thing is when the user uploads only one photo that should be it... but it still tries to upload and move the other, non existent photos. I have an if statement that does not seem to be working.... here it is: <?php //IF THERE IS A FIFTH PICTURE if (isset($_FILES['articlePicFive']) || $_FILES['articlePicFive'] != NULL || $_FILES['articlePicFive'] != '') { $imageName = $gathered['articleId']; // PROCESS IMAGE $target_path = "../images/articles/"; $target_path = $target_path . basename( $_FILES['articlePicFive']['tmp_name']); $_FILES['articlePicFive']['tmp_name']; //MOVE THE IMAGE TO THUMBNAILS move_uploaded_file($_FILES['articlePicFive']['tmp_name'], $target_path); //EXPLODE TO RENAME IMAGE $fileName = $_FILES['articlePicFive']['name']; $broken = explode(".", $fileName); rename("../images/articles/".basename($_FILES['articlePicFive']['tmp_name'])."", "../images/articles/".$imageName."_05." .$broken[1].""); $update = mysql_query("UPDATE articles SET articlePicFive='" .$imageName."_05." .$broken[1]. "' WHERE articleId='".$imageName."'" ) or die(mysql_error()); } ?> What am I doing wrong? See if statement at the start... even though the form fiels is empty it is treating it as there is a file... Thanks Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 13, 2007 Share Posted September 13, 2007 Try using && for and, instead of || for or? Quote Link to comment Share on other sites More sharing options...
Fadion Posted September 13, 2007 Share Posted September 13, 2007 I could try: if($_FILES['articlePicFive']['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.