开发者

error when upload file to remote server (Windows, cURL)

When I use linux this script working. But if I use Windows then script not working. Script:

$url="http://site.com/upload.php";
$post=array('image'=>'@'.getcwd().'\\images\\image.jpg');
$this->ch=curl_init();
curl_setopt($this->ch, CURLOPT_URL, $url);
curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($this->ch, CURLOPT_TIMEOUT, 30);
curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($this->ch, CURLOPT_POST, 1);
curl_setopt(开发者_StackOverflow中文版$this->ch, CURLOPT_POSTFIELDS, $post);
$body = curl_exec($this->ch);
echo $body;

Error in log:

* failed creating formpost data

File exists and readable.


What is printed out when you do:

echo $post['image'];

Does it print out the correct file path? Are you running this as CLI or an Apache installation on Windows? You might have to use:

$post['image'] = '@'.dirname(__FILE__).'\\images\\image.jpg';
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜