Re: using $$foo_name vs. $foo_name for file upload
| From: | raditha dissanayake | Date: | Wed, 07 Jul 2004 05:15:32 +0000 |
| Subject: | Re: using $$foo_name vs. $foo_name for file upload | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-189846@lists.php.net to get a copy of this message | ||
John W. Holmes wrote:
Tony wrote:you might also want to echo out $substitute to see what it contains. -- Raditha Dissanayake. --------------------------------------------- http://www.raditha.com/megaupload/upload.php Sneak past the PHP file upload limits.Trying to use the following statement to upload a file via a form, when I use a variable "$foo" in the following statement it works correctly: if (copy($foo, "./$foo_name")) {//blah... } The name of the file I am trying to upload $foo is evaluated correctly. Likewise I can obtain the file size, "$foo_size". However, it would be advantageous (for reasons that are to complicated to explain here) to use a "variable of a variable" such as "$$foo" however this does not work... if (copy($$foo, "./$$foo_name")) {//blah... } From my testing it appears that the problem has to do with the evaluation of "./$$foo_name". I have tried using a substitute variable such as $substitute = $$foo; if (copy ($substitute, "./$substitute_name")) {//blah... } but that does not work either. Can someone explain how I might get the file name from a $$variable?Variable variables are a cheap man's array. Why not just name all of your file inputs the same and tack a "[]" onto the end of the name. Then you can treat $_FILES as a multi-dimensional array and just loop through it and process it. What John has suggested is the most common way of doing it, if you insist on using variable variables you might want to take a look at eval