【发布时间】:2011-02-01 22:52:36
【问题描述】:
当我使用 linux 时,这个脚本可以工作。但是,如果我使用 Windows,那么脚本将无法正常工作。脚本:
$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($this->ch, CURLOPT_POSTFIELDS, $post);
$body = curl_exec($this->ch);
echo $body;
日志错误:
* 创建表单数据失败
文件存在且可读。
【问题讨论】:
-
不是答案(也不是可能的解决方案),但顺便说一句,在提到路径名时我会使用DIRECTORY_SEPARATOR)。 (或者至少,坚持使用正斜杠 (
/),因为 windows 无所谓,但 *nix 介意)
标签: php windows file curl upload