Jump to content

[SOLVED] Storing server variable name in a string variable.......


TGWSE_GY

Recommended Posts

Okay guys what I am wanting to do is take the server variable $_FILES[''] and store it in a string to loop through to create the appropriate variables and then call that variable to get the file array. Here is my code.

 

$ArrayBaseName = "$_FILES['formImage";
$ArrayBaseNameClose = "']";
$I = 1;
do {
	$ImageArray = $ArrayBaseName . $I . $ArrayBaseNameClose;
	$CurrentImageArray = array("Size" => $ImageArray['size']);
	echo $CurrentImageArray['Size'];
	echo "<br/>";
	echo $ImageArray['Size'];
	$I= $I + 1;
} while ($I<6);

 

All that echos is $ five times. Any ideas of what I am doing wrong?

 

Thanks

:P

Link to comment
Share on other sites

In case my last statements didnt make sense, this is what I am wanting to do.

 

I want to take for instance $_FILES['formImage1'] and store it in a string so I can loop through and create the variable names in code.

 

Please if anyone can help it would be very much appreciated. ??? ??? ??? ??? ??? ??? ??? 8)

Link to comment
Share on other sites

try

<?php
do {
	$ImageArray = $_FILES['formImage'.$I];
	$CurrentImageArray = array("Size" => $ImageArray['size']);
	echo $CurrentImageArray['Size'];
	echo "<br/>";
	echo $ImageArray['size'];
	$I= $I + 1;
} while ($I<6);
?>

Link to comment
Share on other sites

Thanks sasa that coincidentally worked. I will explain what I am doing.

 

I am converting images into base_64 and storing them in mysql that is my ultimate goal.

The user can only upload 5 images max at a time, so I am using recursion to dynamicly pull the information from the form and encode the temp file for the image on the server into base64 and then storing it in a mysql db.

I am wanting to achieve this by using a loop through the process with out having to re-enter code multiple times  ;D I hope this clears it up I have more code with the process of conversion and posting to the database process but that will change somewhat as I recode it in recursion methods, but you are more than willing to see if that will help you understand better of what I am doing.

 

Thanks again sasa! 8);D8)

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.