File Uploads and Get Method

From: Date: Thu, 03 May 2001 18:14:39 +0000
Subject: File Uploads and Get Method
Groups: php.general 
Request: Send a blank email to php-general+get-51304@lists.php.net to get a copy of this message
when i upload a file, the form method must be POST because when GET is used, it adds backslashes to the windows path name that already has backslashes, and this causes an error. for instance, the following snippet of code -- if ($add){ $newimage = "whatever.gif"; copy($image, $directory. "/" .$newimage); } print("<form action=thispage.html action=GET enctype='multipart/form-data'> <input type=file name=image><input type=submit name=add></form>"); produces the following error Warning: Unable to open C:\\My Documents\\My Pictures\\Sample.jpg which is the image i'm trying to upload. notice the double slashes in the path (btw, adding $image = str_replace("\\\\","\\",$image); does not help). so the solution is to use the POST method. now, on the same form, i have a multiple select box, where you can select multiple values from one select box. the code is as follows -- <select name=country size=3 multiple> <option value=3>Australia</option> <option value=4>Brazil</option> <option value=2>Russia</option> <option value=1>USA</option> </select> if the user selects more than one country, then if you echo $country, it will show you only the last selected value for country. however, what you can do is break the query string at the ampersands, figure out all the countries the user has selected and put them in an array. in order to have a query string, the GET mothod must be used. that solves this problem. OOPS....to upload the image, the POST method must be used, but to figure out the values from a multiple select box, the GET method must be used. if i use one, then the other breaks. does anyone have any ideas?

« previous php.general (#51304) next »