重新创建包含cURL的http请求。文件
问题描述:
我始终从下面的代码中得到错误'failed creating formpost data',同样的事情在我的本地测试服务器上完美工作,但在我的共享主机上它会抛出错误。重新创建包含cURL的http请求。文件
示例部分只是模拟用文件和非文件数据构建数组。基本上我在这里试图做的是将相同的http请求重定向到另一台服务器,但我遇到了很多麻烦。
$count=count($_FILES['photographs']['tmp_name']);
$file_posts=array('samplesample' => 'ladeda');
for($i=0;$i<$count;$i++) {
if(!empty($_FILES['photographs']['name'][$i])) {
$fn = genRandomString();
$file_posts[$fn] = "@".$_FILES['photographs']['tmp_name'][$i];
}
}
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,"http://myurl/wp-content/plugins/autol/rec.php");
curl_setopt($ch,CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch,CURLOPT_HEADER,TRUE);
curl_setopt($ch,CURLOPT_POST,TRUE);
curl_setopt($ch,CURLOPT_POSTFIELDS,$file_posts);
curl_exec($ch);
print curl_error($ch);
curl_close($ch);
答
快速谷歌变成了这样:
http://www.phpfreaks.com/forums/index.php?topic=125783.0
看起来你可能需要一些额外的路径信息添加到该行:
$file_posts[$fn] = "@".$_FILES['photographs']['tmp_name'][$i];
卷曲可能不知道哪个目录寻找$_FILES['photographs']['tmp_name'][$i]
英寸
+0
我看过那个页面,并且我尝试添加额外的路径信息。到目前为止没有运气。 – Toby 2010-06-08 18:26:56
应该提到我是你装载一系列文件(照片) - 因此循环 – Toby 2010-06-08 18:10:44