MrLane Posted August 13, 2007 Share Posted August 13, 2007 First post Just a quicky I think but I'm having serious code-blindness here! for($i=1;$i<=3;$i++) { echo($i); if(isset($_FILES["pic".$i]['name'])) { addpicture($i); echo("Uploaded!"); } else { echo("File not uploaded!"); } } What I'm trying to do is check for the existance of a file before I send it to the addpicture() function. There are 3 upload forms each named pic1,pic2,pic3 and I'm trying to loop through them, only executing the function if the forms are filled in. However, it doesn't seem to want to work? Any help appreciated Quote Link to comment https://forums.phpfreaks.com/topic/64655-file-upload-problems/ Share on other sites More sharing options...
frost Posted August 13, 2007 Share Posted August 13, 2007 Can you paste your upload form as well? Do you get any errors? Quote Link to comment https://forums.phpfreaks.com/topic/64655-file-upload-problems/#findComment-322664 Share on other sites More sharing options...
lemmin Posted August 13, 2007 Share Posted August 13, 2007 You are checking if there is an array called pic1 (2, or 3) holding a variable called name inside the array $_FILES. Change this line from: if(isset($_FILES["pic".$i]['name'])) to: if(isset($_FILES["pic".$i])) Quote Link to comment https://forums.phpfreaks.com/topic/64655-file-upload-problems/#findComment-322690 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.