zhahaman2001 Posted May 16, 2007 Share Posted May 16, 2007 I can not get files to upload in and array!! how do i do it? Heres what i got can anyone get this code to work? <?php $files_to_upload = 3; if($step == 2){ for ($i = 1; $i < ($files_to_upload + 1); ++$i) { $file_name = $_FILES['file[$i]']['name']; $upload_dir = "uploads/$file_name"; if(move_uploaded_file($_FILES['file[$i]']['tmp_name'], $upload_dir)) { print "Upload Successfull!"; }else{ print "Error and its all your fault!"; } } } print "<form method='post' enctype='multipart/form-data' name='frm' action='test.php?step=2'>"; for ($i = 1; $i < ($files_to_upload + 1); ++$i) { print "<input type='file' name='file[$i]'><br>"; } print "<input type='submit' value='Upload'>"; print "</form>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/51688-solved-uploading-files-in-an-array-help/ Share on other sites More sharing options...
zhahaman2001 Posted May 16, 2007 Author Share Posted May 16, 2007 Thanks google <?php $files_to_upload = 3; if($step == 2){ for ($i = 1; $i < ($files_to_upload + 1); ++$i) { $tmp_name = $_FILES["file"]["tmp_name"][$i]; $name = $_FILES["file"]["name"][$i]; $upload_dir = "uploads/$name"; if(move_uploaded_file($tmp_name,$upload_dir)) { print "Upload Successfull!"; }else{ print "Error and its all your fault!"; } } } print "<form method='post' enctype='multipart/form-data' name='frm' action='test.php?step=2'>"; for ($i = 1; $i < ($files_to_upload + 1); ++$i) { print "<input type='file' name='file[$i]'><br>"; } print "<input type='submit' value='Upload'>"; print "</form>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/51688-solved-uploading-files-in-an-array-help/#findComment-254675 Share on other sites More sharing options...
pocobueno1388 Posted May 16, 2007 Share Posted May 16, 2007 Google is your friend =] Quote Link to comment https://forums.phpfreaks.com/topic/51688-solved-uploading-files-in-an-array-help/#findComment-254676 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.