[英]Picture uploading using curl/php
我正在嘗試使用curl / php在網站上使用php / curl上傳圖像。 該網站使用ajax / flash將圖像上傳到外部服務器。 當我使用Firebug在網站上手動上傳圖像時,如果圖像成功上傳,我只會收到響應(帶有永久鏈接),但是看不到張貼了哪些參數和數據以及確切位置。
需要上傳圖片的網址:
如何確定需要發送哪些參數才能使圖像成功上傳到網站上?
您提到的特定上載器從以下URL中提取epsToken變量,然后將其用作參數來上載文件。
http://johannesburg.gumtree.co.za/c-GetEpsToken
就我而言,令牌是:
1:b6ac30fa715a395cf728ac29847b2516f701a8f291fd5243d5153eae41c10636
您可以看到我在此處提出的上傳請求的完整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
建議您分析其他參數,並使用其他答案中的代碼來成功上傳圖像。
使用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/
網站圖片上傳時出現了一些問題-它只是彈出一個錯誤
上傳您的圖片時出錯。 請檢查圖像的尺寸和尺寸,然后重試。 如果仍然有問題,可以切換到基本圖像加載器。
對於每種類型的圖像,基本的圖像加載器實際上也無法使用!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.