curl提示failed creating formpost data

来源:互联网 发布:唐泽寿明 知乎 编辑:程序博客网 时间:2024/06/18 06:18
遇到的问题是在linux环境下php文件执行正常,在windows下执行不正常,

度娘得到的结果是

http://blog.csdn.net/hll870909/article/details/7470817

这里有两个地方需要注意:1、$file必须是数组2、上传文件的路径前面加@3、路径必须使用绝对路径

我的代码是
$post = array(         "file"=>"@".$fileStore,         "api_key"=>"xxxxxx",    );    $ch = curl_init();    curl_setopt($ch, CURLOPT_URL, 'http://www.xx.net/');    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);    @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);    curl_setopt($ch, CURLOPT_POST, 1);    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);    $res = curl_exec($ch);    echo curl_error($ch);    curl_close($ch);    return $res;
在linux下使用相对路径是可以的,但是在windows下使用相对路径不可以,直接修改为

$post = array(         "file"=><span style="color:#ff0000;">"@e:\xxx\xxx\"</span>.$fileStore,         "api_key"=>"xxxxxx",    );

就可以了


0 0
原创粉丝点击