Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.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
Php 使用表单自动发送图片_Php_Html_Curl - Fatal编程技术网

Php 使用表单自动发送图片

Php 使用表单自动发送图片,php,html,curl,Php,Html,Curl,我想知道是否有可能自动将图像附加到我服务器上的输入type=“file”中 例如,我希望用户转到显示表单的页面,但当他们提交表单时,它会随表单一起提交picture.png <form action="server I wanna send the picture too"> <input type="text"> <input type="file" value="picture.png" name="img" style="display:none;">

我想知道是否有可能自动将图像附加到我服务器上的输入type=“file”中

例如,我希望用户转到显示表单的页面,但当他们提交表单时,它会随表单一起提交picture.png

<form action="server I wanna send the picture too">
<input type="text">
<input type="file" value="picture.png" name="img" style="display:none;">
</form>
curl_setopt($ch, CURLOPT_URL, 'server I wanna send the picture too');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'img='.file_get_contents('picture.png'));
$answer = curl_exec($ch);
if (curl_error($ch)) {
    echo curl_error($ch);
}