Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用cURL将图像上传到PHP服务器?_Php_Curl_Server_Debian_Ubuntu 16.04 - Fatal编程技术网

使用cURL将图像上传到PHP服务器?

使用cURL将图像上传到PHP服务器?,php,curl,server,debian,ubuntu-16.04,Php,Curl,Server,Debian,Ubuntu 16.04,使用非常简单的PHP服务器: <?php $file = date("YmdHisms") . ".jpg"; file_put_contents($file, file_get_contents("php://input")); ?> 或: 或: 正在我的web服务器目录中创建文件,但图像似乎没有打开?我这里出了什么问题?试试这个: curl -i -X POST -H "Content-Type: multipart/form-data" -F "image=@image.j

使用非常简单的PHP服务器:

<?php
$file = date("YmdHisms") . ".jpg";
file_put_contents($file, file_get_contents("php://input"));
?>
或:

或:

正在我的web服务器目录中创建文件,但图像似乎没有打开?我这里出了什么问题?

试试这个:

curl -i -X POST -H "Content-Type: multipart/form-data" -F "image=@image.jpg" http://192.168.1.3
将php代码更改为

<?php
   $file = date("YmdHisms") . ".jpg";
   move_uploaded_file($_FILES['image']['tmp_name'], $file);
?>

cat image.jpg | curl --data - 'http://192.168.1.3'
curl -i -X POST -H "Content-Type: multipart/form-data" -F "image=@image.jpg" http://192.168.1.3
<?php
   $file = date("YmdHisms") . ".jpg";
   move_uploaded_file($_FILES['image']['tmp_name'], $file);
?>