Jump to content

For Every $_POST


tarun

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.