[英]File upload to remote server using php without form post / cURL POST method
[英]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永久移動”
我怎么了 謝謝。
您可以使用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.