我正在尝试上传图片使用php/curl在一个网站上使用curl/php。网站使用ajax/flash上传图片到外部服务器。当我使用firebug在网站上手动上传图像时,如果图像成功上传,我只会收到响应(带有永久链接),但我看不到发布了哪些参数和数据以及确切位置。
需要上传图片的web url:
http://tinyurl.com/bp779wx
如何了解需要发送哪些参数才能将图片成功上传到网站?
发布于 2013-02-20 20:57:08
您提到的特定上传器从下面的URL中提取epsToken变量,然后将其用作上传文件的参数。
http://johannesburg.gumtree.co.za/c-GetEpsToken
在我的例子中,令牌是:
1:b6ac30fa715a395cf728ac29847b2516f701a8f291fd5243d5153eae41c10636
您可以查看我发出的here上传请求的完整POST数据。请记住,这是一个多部分/表单数据请求,因此您可能需要调整curl/PHP代码以支持该请求。
基本上,通过POST请求提供了以下参数:
Filename = Image.png
b = 18
s = 1C5000
n = k
a = 1:b6ac30fa715a395cf728ac29847b2516f701a8f291fd5243d5153eae41c10636
v = k
r = 0
u = the actual image, sent as a multipart stream
Upload = Submit Query我建议您分析其他参数并使用其他答案中的代码,以便成功上传图像。
发布于 2013-02-18 13:59:30
用PHP和cURL上传图片。
function curl_post_request($url, $data, $referer='') {
$data = http_build_query($data); // seems to be required arrays should'nt be supported ? whatever.
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $url);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_HEADER, true);
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, $data);
curl_setopt($c, CURLOPT_REFERER, $referer);
curl_setopt($c, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1");
curl_setopt($c, CURLOPT_HEADER, $headers);
curl_setopt($c, CURLINFO_HEADER_OUT, true);
curl_setopt($c, CURLOPT_VERBOSE, true);
$output = curl_exec($c);
var_dump(curl_getinfo($c, CURLINFO_HEADER_OUT));
//var_dump($data);
if($output === false) trigger_error('Erreur curl : '.curl_error($c),E_USER_WARNING);
curl_close($c);
return $output;
}
if(isset($_GET['GO'])) {
$data = array(
'pic1' => "@".realpath('image.jpg'),
'postedvar1' => 'test1',
'postedvar2' => 'test2'
);
$url = 'http://localhost/test/index.php';
$a = curl_post_request($url, $data);
var_dump($a);
} else {
print_r($_POST);
print_r($_FILES);
}使用CURL + PHP通过远程表单上传图片
$info = array('test title','1234','virginia','@'.realpath('e:\wamp
\www\1.jpg'),'@'.realpath('e:\wamp\www\2.jpg'),'@'.realpath('e:\wamp\www
\3.jpg'),'@'.realpath('e:\wamp\www\4.jpg'),'test description');
$post->postAd($url, $info);另外,请阅读此文
http://www.maheshchari.com/upload-image-file-to-remote-server-with-php-curl/
并查看此链接
http://blog.smileylover.com/remote-upload-to-imageshackus-with-phpcurl/
和
http://blogs.digitss.com/php/curl-php/posting-or-uploading-files-using-curl-with-php/
发布于 2013-02-18 14:40:30
网站上传的图片有一些问题-它只是弹出了一个错误
上载您的照片时出错。请检查图像大小和尺寸,然后重试。如果您仍然有问题,您可以切换到基本镜像加载器。
对于每种类型的图像和基本的图像加载器也不是实际可用的!
https://stackoverflow.com/questions/14861771
复制相似问题