tarun Posted June 10, 2007 Share Posted June 10, 2007 Basically Ive Got Lots Of POSTs For A Multi-File Uploader It Needs To Run Through All The POST Variables eg file_1 file_2 file_3 etc. I Would Think It Could Be Done With for Or foreach But Im Not Sure How So If Anyone Does Or Can Point Me In The Write Direction Please Post A Message Here K Thnx Quote Link to comment https://forums.phpfreaks.com/topic/54995-for-every-_post/ Share on other sites More sharing options...
pocobueno1388 Posted June 10, 2007 Share Posted June 10, 2007 Try this: <?php foreach ($_POST as $key => $val){ echo $key.'-'.$val.'<br>'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/54995-for-every-_post/#findComment-271898 Share on other sites More sharing options...
Hypnos Posted June 10, 2007 Share Posted June 10, 2007 If you know what the last number will be, it's easy. This is just one way that comes to mind: for ($index = 1; $index < 30; $index++) { echo $_POST['file_' . $index]; } If you don't know the last number, use while($_POST['file_' . $index]), and increment $index. Quote Link to comment https://forums.phpfreaks.com/topic/54995-for-every-_post/#findComment-271910 Share on other sites More sharing options...
tarun Posted June 10, 2007 Author Share Posted June 10, 2007 Unfortunatley None Of These Methods Worked The First Two Provided No Output And This: <?php $index=1; while($_POST["file_".$index]<=10){ echo "File $index Uploaded<BR>\n"; $index++; } ?> Just Listed An Everlasting List Of Numbers. eg. File 1 Uploaded File 2 Uploaded File 3 Uploaded File 4 Uploaded File 5 Uploaded etc. Quote Link to comment https://forums.phpfreaks.com/topic/54995-for-every-_post/#findComment-271924 Share on other sites More sharing options...
chigley Posted June 10, 2007 Share Posted June 10, 2007 <?php foreach($_POST as $key => $value) { // $key contains the POST field name from the form // $value contains the file name input (may want to filter here..) // After filtering, upload file... } ?> Quote Link to comment https://forums.phpfreaks.com/topic/54995-for-every-_post/#findComment-271925 Share on other sites More sharing options...
pocobueno1388 Posted June 10, 2007 Share Posted June 10, 2007 Yeah, you actually have to submit the information for it to show up. The code I provide should be on the file where the form action is directed at. Quote Link to comment https://forums.phpfreaks.com/topic/54995-for-every-_post/#findComment-271934 Share on other sites More sharing options...
tarun Posted June 11, 2007 Author Share Posted June 11, 2007 Yes I Know However I Shall Try Again Quote Link to comment https://forums.phpfreaks.com/topic/54995-for-every-_post/#findComment-272340 Share on other sites More sharing options...
tarun Posted June 11, 2007 Author Share Posted June 11, 2007 This Works As Mentioned By "chigley" And "pocobueno1388 " <?php foreach($_POST as $key => $value) { } ?> Is There A Way How I Can Make It More Advanced Since At The Moment It Uses All The $_POST Variables How Do I Do It So It Only Uploads Fields With file_1 , file_2, file_3 etc. Up To An Unlimited Amount Quote Link to comment https://forums.phpfreaks.com/topic/54995-for-every-_post/#findComment-272361 Share on other sites More sharing options...
trq Posted June 11, 2007 Share Posted June 11, 2007 <?php foreach($_POST as $key => $value) { if (substr($key,0,4) == 'file') { echo "$key => $value"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/54995-for-every-_post/#findComment-272363 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.