2013-11-22 56 views
1

我想從iphone上傳圖像到服務器。使用ASIHttpRequestASIFormDataRequest我已經用字典上傳圖像

[request setdata:...] 

成功地uplaoded圖片服務器,但我也想送用戶id到服務器的圖像。如何實現這一目標?這裏是我的代碼...

ASIFormDataRequest *_request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:URLSaveImage]]; 
__unsafe_unretained ASIFormDataRequest *request = _request; 
[ASIHTTPRequest setShouldThrottleBandwidthForWWAN:YES]; 
[request setUploadProgressDelegate:self]; 
NSData *data=UIImageJPEGRepresentation(proImage.image,1.0); 
[request setData:data 
    withFileName:@"profile.jpg" 
    andContentType:@"image/jpeg" 
      forKey:@"file"]; 
+0

使用字典鍵值對,再添加一個用戶ID的鍵。 –

+0

你的請求方法是什麼? – Venkat

+0

這裏是我的代碼你可以告訴我如何使用它的字典 – vivek

回答

1

對於POST方法,使用setPostValue:forKey:使用setData:。你不需要做任何額外的工作。只需將圖像與變量一起發佈即可。

[request setPostValue:VALUE forKey:KEY]; 
[request setData:data withFileName:@"profile.jpg" andContentType:@"image/jpeg" 
     forKey:@"file"]; 
+0

但如何添加圖像和一個更多的提交VALUE – vivek

+0

好所以另一個領域,我必須設置VALUE與setPostvalue和圖像setdata ??? – vivek

+0

是............ – manujmv