如何将HTML文件内容从PHP传递到CGI(Perl)脚本

如何将HTML文件内容从PHP传递到CGI(Perl)脚本

问题描述:

The content of the an HTML file generated by a PHP is stored in a string variable called

$output

I am trying to send the contents in $output to a CGI script.

I have tried the following CURL in PHP...

$output = "long string, with strange non HTML characters..."
$c = curl_init();
curl_setopt($c, CURLOPT_URL, 'http://www.example.com/cgi-bin/script.cgi');
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, $output);
curl_exec ($c);
curl_close ($c);

...but I only get a small part of the $output content.

Do you have any recommendations on how to pass the content of $output from PHP to the CGI/Perl script?

Thanks!

PHP生成的HTML文件的内容存储在名为 p> 的字符串变量中 $ output code> pre>

我正在尝试将$ output中的内容发送到CGI脚本。 p>

我在PHP中尝试了以下CURL ... p>

  $ output =“long string,with strange non HTML characters ...”
 $ c = curl_init  (); 
curl_setopt($ c,CURLOPT_URL,'http://www.example.com/cgi-bin/script.cgi');
curl_setopt($c,CURLOPT_POST,true); 
curl_setopt($ c,CURLOPT_POSTFIELDS  ,$ output); 
curl_exec($ c); 
curl_close($ c); 
  code>  pre> 
 
 

...但我只收到$ output的一小部分 内容。 p>

您对如何将$ output的内容从PHP传递到CGI / Perl脚本有什么建议吗? p>

谢谢! div>

I don't know if it suits you but you can do that:

curl_setopt($c, CURLOPT_POSTFIELDS, array("output" => $output));

This will sent your data as value of the POST field named 'output'

You may also use socket functions to open connection to server and send your own fully custom http request.