2
我試圖使用ASIFormDataRequest從我的 iPhone應用程序發送照片圖像到我的服務器。嘗試使用ASIFormDataRequest將圖像從iPhone上傳到服務器
當我這樣做時,服務器發送回一個錯誤 消息說「必須是圖像文件」,暗示有 我的圖像的格式有問題。 (當然, 可能不是問題...但它是一個開始的好地方。)我知道 本身在服務器上沒有「問題」,因爲我使用的以前的 方法(非ASIHTTPRequest基於)工作正常。 這裏是我的iPhone代碼:
ASIFormDataRequest* request = [ASIFormDataRequest requestWithURL:
[NSURL URLWithString:photoUploadURLString]];
request.username = self.username;
request.password = self.password;
[request setPostValue:self.place.placeId forKey:@"place_id"];
NSData* jpegImageData = UIImageJPEGRepresentation(self.photo,
PHOTO_JPEG_QUALITY);
NSString* filename = [NSString stringWithFormat:@"snapshot_%@_
%d.jpg", self.place.placeId, rand()];
[request setData:jpegImageData withFileName:filename
andContentType:@"image/jpeg" forKey:@"snapshot[image]"];
request.uploadProgressDelegate = self.progressView;
[request startSynchronous];
任何人都看到有什麼不對嗎? (我對這個東西相當陌生,所以 可能有些東西顯而易見,我很想念。)
非常感謝。
嗨,fayasar - 我實際上是在一個完全不同的公司,現在,我不知道我最終如何解決這個問題!但是您推薦的解決方案:使用addData,並使用類似於快照[image]的鍵,聽起來是正確的。謝謝你的幫助。 – 2010-10-07 16:34:47
歡迎您,新公司好運 – fyasar 2010-10-07 19:35:35