繁体   English   中英

没有表单发布到远程文件

[英]Post to remote file without a form

不使用表单,是否可以_POST到其他文件?

就我而言,我想通过_POST发送一个字符串到该文件。

谢谢。


更新:

根据对我的帖子的回复,我使用了以下内容:

<?php

$ipCreation = $_SERVER['REMOTE_ADDR'];

$ipCreationCurl = curl_init(); // initiate curl
$url = "accountcreation.php"; // where you want to post data
curl_setopt($ipCreationCurl, CURLOPT_URL,$url);
curl_setopt($ipCreationCurl, CURLOPT_POST, true);  // tell curl you want to post something
curl_setopt($ipCreationCurl, CURLOPT_POSTFIELDS, $ipCreation); // define what you  want to post
curl_setopt($ipCreationCurl, CURLOPT_RETURNTRANSFER, true); // return the output in string format
$output = curl_exec ($ipCreationCurl); // execute

curl_close ($ipCreationCurl); // close curl handle

var_dump($output); // show output
?>

返回:

“ 308永久移动”


“ nginx”

我怎么了 谢谢。

您可以使用curl发布。 这是一个基本示例: http : //devzone.co.in/post-data-using-curl-in-php-a-simple-example/

$ch = curl_init();                    // initiate curl
$url = "http://www.somesite.com/curl_example.php"; // where you want to post data
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, true);  // tell curl you want to post something
curl_setopt($ch, CURLOPT_POSTFIELDS, "var1=value1&var2=value2&var_n=value_n"); // define what you  want to post
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return the output in string format
$output = curl_exec ($ch); // execute

curl_close ($ch); // close curl handle

var_dump($output); // show output

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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