Need $_FILES traverse listing help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
DixieGal
Forum Newbie
Posts: 1
Joined: Tue Oct 21, 2003 10:52 am
Contact:

Need $_FILES traverse listing help

Post by DixieGal »

Ok. First, be gentle. My PHP code is currently being updated to meet some of the more stringent 4.3.3 guidelines. This coming when a 4.1.x happy client had their site quit uploading photos after host upgraded
to 4.3.3.

I also use a code generator, only plugging in PHP where needed, which is why you see <? ?> instead of the entire code being inside PHP format

Here goes:
I have a form that allows users to upload up to 9 photos. Instead of creating 9 title, description, file inputs, I created a loop as such:


<FORM ENCTYPE="multipart/form-data" ACTION="./adminphotorespond.php" METHOD=POST>
<INPUT TYPE=HIDDEN NAME="contactid" VALUE="<?=$contactid?>">
<INPUT TYPE=HIDDEN NAME="cid" VALUE="<?=$cid?>">
<INPUT TYPE=HIDDEN NAME="max_file_size" VALUE="2000">
<INPUT TYPE=HIDDEN NAME="uid" VALUE="<?=$siteuserid?>">
<INPUT TYPE=HIDDEN NAME="converseid" VALUE="<?=$converseid?>">

<? $i=0;
$rphototitle = array();
$rphotodesc = array();
$rlocation= array();

while ($i <=9 )
{
?>

<B>Photo Title:</B>
<INPUT TYPE=TEXT NAME="rphototitle<?=$i?>" VALUE="" SIZE=58 MAXLENGTH=65>
<B>Description:</B> </p>
<TEXTAREA WRAP=PHYSICAL NAME="rphotodesc<?=$i?>" ROWS=4 COLS=55></TEXTAREA>

<P><B>Location:</B>
<INPUT TYPE="FILE" NAME="rlocation<?=$i?>"VALUE="" SIZE=50 MAXLENGTH=60 ></P>
<? $i++; } ?>


what USED to be created (pre4.3.3) were POST variables

rphototitle0= 'stringvalue'
rphototitle1='stringvalue'
:
:
rphotodesc0='description'
rphotodesc0='description'
:
:
rlocation0=filename
rlocation1=filename


I was able in the called page to process the value of the filename and upload the images. This quit working in 4.3.3 The title and description still work, but the filename doesn't. I am having a hard time getting my brain wrapped around multi-dimensional arrays.
I can figure out to process and convert my code using the $_FILES method IF I could get a snipped of code that will traverse my entire $_FILES array and echo a formatted way what each element name is and looks like something like this:



$_FILES[somekeyvalue]['name'] =>filename
$_FILES[somekeyvalue]['tmp_name'] =>filetempname
$_FILES[somekeyvalue]['size'] => size
$_FILES[somekeyvalue]['type'] => type
:
:



What I would like is something similar to what this does for $_POST variables:
<?reset ($_POST);
while (list ($key, $val) = each ($_POST))
{ echo("$"."$key =". $_POST["$key"]."<br>"); }?>


:?: Any help I can get would be GREATLY appreciated!!!
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

testing...
Post Reply