简体   繁体   中英

How can I pass an HTML file content from PHP to CGI (Perl) Script

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM