TGWSE_GY Posted April 28, 2009 Share Posted April 28, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/155936-solved-storing-server-variable-name-in-a-string-variable/ Share on other sites More sharing options...
TGWSE_GY Posted April 28, 2009 Author Share Posted April 28, 2009 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. ??? ??? ??? ??? ??? ??? ??? Quote Link to comment https://forums.phpfreaks.com/topic/155936-solved-storing-server-variable-name-in-a-string-variable/#findComment-820846 Share on other sites More sharing options...
.josh Posted April 28, 2009 Share Posted April 28, 2009 Are you saying you want php to parse a string as if it were code? eval Though if you explained what your overall goal here is, there's probably a better solution... Quote Link to comment https://forums.phpfreaks.com/topic/155936-solved-storing-server-variable-name-in-a-string-variable/#findComment-820853 Share on other sites More sharing options...
sasa Posted April 28, 2009 Share Posted April 28, 2009 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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/155936-solved-storing-server-variable-name-in-a-string-variable/#findComment-820855 Share on other sites More sharing options...
TGWSE_GY Posted April 28, 2009 Author Share Posted April 28, 2009 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 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! Quote Link to comment https://forums.phpfreaks.com/topic/155936-solved-storing-server-variable-name-in-a-string-variable/#findComment-820868 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.