Re: Re: HTTP_POST_VARS not a multi-dimensional array?
| From: | Caleb Shay | Date: | Sun, 17 Dec 2000 21:32:51 +0000 |
| Subject: | Re: Re: HTTP_POST_VARS not a multi-dimensional array? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-30769@lists.php.net to get a copy of this message | ||
I thought that what you would be looking for is $HTTP_POST_FILES['userfile_name'] and $HTTP_POST_FILES['userfile_type']
Caleb Shay
caleb@webninja.com
Haig C Didizian wrote:
Hi -Sorry about that... I just realized after I sent last message it that Ishould have been using $HTTP_POST_FILES instead of $HTTP_POST_VARS. So I updated my stuff to reflect that, and when I try something like : print $HTTP_POST_FILES['userfile']['name']; it's empty. The only variable that appears to be set to something useful is $userfile, and that prints out the path to the file from the uploading machine (should that be the path to the file on the server?). Thanks again, Haig ----- Original Message ----- From: "Haig C Didizian" <hcd@seas.upenn.edu> To: <php-general@lists.php.net> Sent: Sunday, December 17, 2000 1:28 PM Subject: HTTP_POST_VARS not a multi-dimensional array?Hi,theI'm new to PHP, so forgive me if I'm making a really stupid mistakehere. I'd like to post a file through a form: <form method=post action=bm_upload_2.php> <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="10240"> <input type=file name=userfile><br> <input type=submit> </form> when i run this code, which i picked up off php.net: <? echo "Values submitted via POST method:<br>"; reset ($HTTP_POST_VARS); while (list ($key, $val) = each ($HTTP_POST_VARS)) {echo "$key => $val<br>";} ?> i get the following result: Values submitted via POST method: MAX_FILE_SIZE => 10240 userfile => A:\\talk.txt Now, the php manual concerning post file uploads makes it clear that HTTP_POST_VARS['userfile'] should be an array, but when I try to get the type or size via $HTTP_POST_FILES['userfile']['type'], etc., I only getfirst letter of userfile - which in this case is 'A'. So, it seems to me that unless I'm missing some basic element of PHP syntax, HTTP_POST_FILES['userfile'] is just a string, not an associative array. AmIdoing something wrong here? Another thing: I'm using the following code to move the file to my /tmp directory: <? if (move_uploaded_file($userfile, "/tmp/")) { print("move succeeded"); } else { print("move failed"); } ?> and it continually prints "move failed". I imagine that this is related to the post_vars problems, but maybe there's another problem in there... My setup is: Apache 1.3.14, PHP 4.0.3pl1, mod_ssl 2.7.1 (I'm testing this over SSL) Thanks so much, Haig Didizian hcd@seas.upenn.edu