Re: Question in posting form-data
| From: | Erwin Kerk | Date: | Thu, 16 Dec 2004 12:30:57 +0000 |
| Subject: | Re: Question in posting form-data | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-204485@lists.php.net to get a copy of this message | ||
Yao, Minghua wrote:
Hi, all, I am testing how to post form-data to a host using the following code (test.php): <?phpCheck your function carefully. Where are you using the $name of the value? Nowhere! Therefore the receiving script cannot identify the value as x. Try: fputs($fp, "$name=$value\n"); Erwinfunction PostToHost($host, $path, $name, $value) { // Test of posting form-data$fp = fsockopen($host,80); fputs($fp, "POST $path HTTP/1.1\n"); fputs($fp, "Host: $host\n"); fputs($fp, "Content-Type: multipart/form-data\n"); fputs($fp, "content-disposition: form-data; name=$name\n"); fputs($fp, "Connection: close\n\n"); fputs($fp, "$value\n"); $res = ""; while(!feof($fp)) {$res .= fgets($fp, 128);} fclose($fp); return $res; }