2010-05-07 117 views
1

我想使用php cURL將圖片上傳到特定網站,但我並不真正瞭解需要發送什麼參數,因爲數據看起來有點奇怪。這裏是我用http分析器得到的其他參數
Type : multipart/form-data; boundary=---------------------------182983931283 -----------------------------182983931283 Content-Disposition: form-data; name="file"; filename="Blue hills.jpg"
Content-Type: image/jpeg
curl post picture multipart/form-data,php cURL需要幫助!

Here appears the souce of the image itself like "ÿØÿàÿØÿàÿØÿàÿØÿàÿØÿàÿØÿà" -----------------------------182983931283 Content-Disposition: form-data; name="action" images -----------------------------182983931283 Content-Disposition: form-data; name="anonymous_email"

Y -----------------------------182983931283 Content-Disposition: form-data; name="site_id"

1 -----------------------------182983931283 等等。我的問題是,我不明白邊界是什麼,我從哪裏得到它(因爲它沒有出現在生成POST的html文檔中,我應該如何發佈帖子。如果你願意我一個簡單的例子來發布上述參數http://example.com我一定會得到的伎倆 目前我使用下面的功能,使帖子:

 function processPicturesPage($title, $price, $numbedrooms, $description) {  //Set the login parameters and initiate the Login process  
    $fields = array(

「changedImages」 =>「」, 「 site_id「=>」1「, 」posting_id「=>」「, 」current_live_date「=>」「, 」images_loaded「=>」「, 」image_actions「=>」「, 「title」=> $ title,

); foreach($ fields as $ key => $ value){ $ fields_string。= $ key。'='。$ value。' &'; } rtrim($ fields_string,'&'); $ URL =「http://www.example.com/cgi-bin/add_posting.pl」; return $ this-> processCurlrequest($ URL,count($ fields),$ fields_string); }

並在processCurlrequest我有捲曲選項(cookie等)和網址。

+2

呃,試着格式化你的問題! – metrobalderas 2010-05-07 17:13:53

回答

2

發送多部分數據時,邊界將用作每個字段之間的分隔符。這些邊界是由cURL自動創建的,你不需要擔心它們。