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

发布于 2024-08-28 13:39:49 字数 540 浏览 2 评论 0原文

PHP 生成的 HTML 文件的内容存储在名为“

$output

我正在尝试将 $output 中的内容发送到 CGI 脚本”的字符串变量中。

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

$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);

...但我只得到了 $output 内容的一小部分。

您对如何将 $output 的内容从 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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

微暖i 2024-09-04 13:39:50

我不知道它是否适合您,但您可以这样做:

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

这会将您的数据作为名为“output”的 POST 字段的值发送

您还可以使用套接字函数打开与服务器的连接并发送您自己的完全自定义的 http 请求。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文