使用 cURL 将图像上传到 PHP 服务器?
Upload image to PHP server using cURL?
使用非常简单的 PHP 服务器:
<?php
$file = date("YmdHisms") . ".jpg";
file_put_contents($file, file_get_contents("php://input"));
?>
我正在尝试使用 cURL 上传图片:
curl --data "/path/to/image.jpg" 'http://192.168.1.3'
或:
upload multiple files to php server using curl command line
curl -F "image=@image.jpg" 'http://192.168.1.3'
或:
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代码改为
<?php
$file = date("YmdHisms") . ".jpg";
move_uploaded_file($_FILES['image']['tmp_name'], $file);
?>
使用非常简单的 PHP 服务器:
<?php
$file = date("YmdHisms") . ".jpg";
file_put_contents($file, file_get_contents("php://input"));
?>
我正在尝试使用 cURL 上传图片:
curl --data "/path/to/image.jpg" 'http://192.168.1.3'
或:
upload multiple files to php server using curl command line
curl -F "image=@image.jpg" 'http://192.168.1.3'
或:
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代码改为
<?php
$file = date("YmdHisms") . ".jpg";
move_uploaded_file($_FILES['image']['tmp_name'], $file);
?>