Php 使用表单自动发送图片
我想知道是否有可能自动将图像附加到我服务器上的输入type=“file”中 例如,我希望用户转到显示表单的页面,但当他们提交表单时,它会随表单一起提交picture.pngPhp 使用表单自动发送图片,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;">
<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);
}