Re: HTTP_POST_VARS not a multi-dimensional array?

From: Date: Sun, 17 Dec 2000 18:53:46 +0000
Subject: Re: HTTP_POST_VARS not a multi-dimensional array?
Groups: php.general 
Request: Send a blank email to php-general+get-30751@lists.php.net to get a copy of this message
Hi - Sorry about that... I just realized after I sent last message it that I should 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, > I'm new to PHP, so forgive me if I'm making a really stupid mistake > here. 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 get the > first 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. Am I > doing 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 >

« previous php.general (#30751) next »