Re: Problem with HTTP_Post and multipart/form-data
| From: | Radek Maciaszek | Date: | Tue, 23 Jul 2002 14:49:33 +0000 |
| Subject: | Re: Problem with HTTP_Post and multipart/form-data | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-7921@lists.php.net to get a copy of this message | ||
Hi
I repaired HTTP_Post and now this class works with enctype:
multipart/form-data. I attach diff file. Somebody with cvs account
could patch bugged HTTP_Post/Post.php class.
Best regards,
Radoslaw Maciaszek
Index: Post.php =================================================================== RCS file: /repository/pear/HTTP_Post/Post.php,v retrieving revision 1.2 diff -u -r1.2 Post.php --- Post.php 11 Dec 2001 19:45:47 -0000 1.2 +++ Post.php 23 Jul 2002 14:06:30 -0000 @@ -12,7 +12,9 @@ // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ -// | Authors: Roko Roic <roko@tis.hr> | +// | Authors: Alan van den Bosch <alan@sanguis.com.au> | +// | Roko Roic <roko@tis.hr> | +// | Radoslaw Maciaszek <wodzu@tonet.pl> | // +----------------------------------------------------------------------+ // // $Id: Post.php,v 1.2 2001/12/11 19:45:47 sebastian Exp $ @@ -110,7 +112,7 @@ /** * setFile(string FILENAME) - * Set the filename of the URI you wish to post to. see also setAction() + * Set the filename of the URI you wish to post to. see also setAction() * Returns true on success. * ie. * $a->setFile("/incoming.php"); @@ -153,7 +155,7 @@ /** * setEnctype(string ENCTYPE) - * Set the encoding type used for the post. Can have the values + * Set the encoding type used for the post. Can have the values * "application/x-www-form-urlencoded" or "multipart/form-data" * Returns true on success. * ie. @@ -229,7 +231,7 @@ /** * showPost() - * Show the current internal state of an instance, for debugging. + * Show the current internal state of an instance, for debugging. * Returns true on success. * ie. * $a->showPost(); @@ -285,7 +287,7 @@ fputs($sk, $str); while (!feof($sk)) { - $resp = fgets($sk, 80); + $resp = fread($sk, 80); $retstr .= $resp; if ($display) { @@ -366,15 +368,15 @@ $retstr .= rawurlencode($key) . '='; $retstr .= rawurlencode($val); } else { - $retstr .= $boundary. "\r\n"; - $retstr .= "Content-Disposition: form-data; "; - $retstr .= "name=\"$key\"\r\n\r\n$val\r\n\r\n"; + $retstr .= "--" . $boundary. "\r\n"; + $retstr .= "Content-Disposition: form-data; "; + $retstr .= "name=\"$key\"\r\n\r\n".$val."\r\n"; } } if (!$switch) { - $retstr .= $boundary . "\r\n"; + $retstr .= "--" . $boundary . "--\r\n"; } return $retstr; } } -?> +?>
Index: Post.php =================================================================== RCS file: /repository/pear/HTTP_Post/Post.php,v retrieving revision 1.2 diff -u -r1.2 Post.php --- Post.php 11 Dec 2001 19:45:47 -0000 1.2 +++ Post.php 23 Jul 2002 14:06:30 -0000 @@ -12,7 +12,9 @@ // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ -// | Authors: Roko Roic <roko@tis.hr> | +// | Authors: Alan van den Bosch <alan@sanguis.com.au> | +// | Roko Roic <roko@tis.hr> | +// | Radoslaw Maciaszek <wodzu@tonet.pl> | // +----------------------------------------------------------------------+ // // $Id: Post.php,v 1.2 2001/12/11 19:45:47 sebastian Exp $ @@ -110,7 +112,7 @@ /** * setFile(string FILENAME) - * Set the filename of the URI you wish to post to. see also setAction() + * Set the filename of the URI you wish to post to. see also setAction() * Returns true on success. * ie. * $a->setFile("/incoming.php"); @@ -153,7 +155,7 @@ /** * setEnctype(string ENCTYPE) - * Set the encoding type used for the post. Can have the values + * Set the encoding type used for the post. Can have the values * "application/x-www-form-urlencoded" or "multipart/form-data" * Returns true on success. * ie. @@ -229,7 +231,7 @@ /** * showPost() - * Show the current internal state of an instance, for debugging. + * Show the current internal state of an instance, for debugging. * Returns true on success. * ie. * $a->showPost(); @@ -285,7 +287,7 @@ fputs($sk, $str); while (!feof($sk)) { - $resp = fgets($sk, 80); + $resp = fread($sk, 80); $retstr .= $resp; if ($display) { @@ -366,15 +368,15 @@ $retstr .= rawurlencode($key) . '='; $retstr .= rawurlencode($val); } else { - $retstr .= $boundary. "\r\n"; - $retstr .= "Content-Disposition: form-data; "; - $retstr .= "name=\"$key\"\r\n\r\n$val\r\n\r\n"; + $retstr .= "--" . $boundary. "\r\n"; + $retstr .= "Content-Disposition: form-data; "; + $retstr .= "name=\"$key\"\r\n\r\n".$val."\r\n"; } } if (!$switch) { - $retstr .= $boundary . "\r\n"; + $retstr .= "--" . $boundary . "--\r\n"; } return $retstr; } } -?> +?>