file_get_contents():假设 application/x-www-form-urlencoded 未指定内容类型
file_get_contents(): Content-type not specified assuming application/x-www-form-urlencoded
我有一个 php 和 javascript 的项目...我有一个 API 来自相机的 Php 代码调用。我使用了 (file_get_contents) 函数和 Post 请求:此代码:
$value = $_POST['TakeNewPic'];
function Takepic(){
$Parametrs = $value;
$opts = array(
"user" => "THETAYN10113693",
"password" => "10113693",
"name" => $Parametrs
);
$post = json_encode($opts);
$context = stream_context_create(array(
'http' => array(
'method' => "POST",
'timeout' => 60,
'content' => $post,
'header' => "Content-Type : application/json"
)
));
$url = 'http://192.168.1.1/osc/commands/execute';//.$https_server;
$result = file_get_contents($url,false, $context);
echo json_encode($result);
//}
}
此代码有效,相机可以拍照,但问题是我总是收到此通知:
注意:file_get_contents():假定 C:\xampp7.3\htdocs\CameraTest\function.php 中的 application/x-www-form-urlencoded 第 63 行
未指定内容类型]
然后我通过 Ajax 从 Java 脚本文件调用将值发送到 php 文件这是 Java 脚本文件中的代码:
function getCamInfo(value)
{
var body = "TakeNewPic=" + value ;
var req = new XMLHttpRequest();
req.onreadystatechange = function ()
{
if(this.readyState === 4 && this.status === 200){
var res = document.getElementById("parg");
res.innerHTML =this.responseText;
}
}
req.open (
"POST",
"post_req.php",
true,
);
req.setRequestHeader(
"content-type",
"application/x-www-form-urlencoded"
);
req.send(body);
}
document.getElementById("butt").onclick = function ()
{
getCamInfo("camera.takePicture");
//console.log(AllInfo);
}
请不要再收到此通知我希望得到你的帮助,非常感谢
我有一个 php 和 javascript 的项目...我有一个 API 来自相机的 Php 代码调用。我使用了 (file_get_contents) 函数和 Post 请求:此代码:
$value = $_POST['TakeNewPic'];
function Takepic(){
$Parametrs = $value;
$opts = array(
"user" => "THETAYN10113693",
"password" => "10113693",
"name" => $Parametrs
);
$post = json_encode($opts);
$context = stream_context_create(array(
'http' => array(
'method' => "POST",
'timeout' => 60,
'content' => $post,
'header' => "Content-Type : application/json"
)
));
$url = 'http://192.168.1.1/osc/commands/execute';//.$https_server;
$result = file_get_contents($url,false, $context);
echo json_encode($result);
//}
}
此代码有效,相机可以拍照,但问题是我总是收到此通知:
注意:file_get_contents():假定 C:\xampp7.3\htdocs\CameraTest\function.php 中的 application/x-www-form-urlencoded 第 63 行
未指定内容类型]然后我通过 Ajax 从 Java 脚本文件调用将值发送到 php 文件这是 Java 脚本文件中的代码:
function getCamInfo(value)
{
var body = "TakeNewPic=" + value ;
var req = new XMLHttpRequest();
req.onreadystatechange = function ()
{
if(this.readyState === 4 && this.status === 200){
var res = document.getElementById("parg");
res.innerHTML =this.responseText;
}
}
req.open (
"POST",
"post_req.php",
true,
);
req.setRequestHeader(
"content-type",
"application/x-www-form-urlencoded"
);
req.send(body);
}
document.getElementById("butt").onclick = function ()
{
getCamInfo("camera.takePicture");
//console.log(AllInfo);
}
请不要再收到此通知我希望得到你的帮助,非常感谢