2010-11-29 124 views
0

我正在嘗試編寫一個iPhone應用程序,該應用程序允許我通過多部分表單上傳JPG圖像。通過iPhone在多部分表格上傳圖像的問題

有時,上傳的照片在服務器上出現奇怪的像素時會損壞,並且照片看起來會被裁剪掉。

這可能是什麼原因? 我怎麼沒有從服務器得到http錯誤響應? (上傳後端被寫入PHP)

回答

0

可以使用base64編碼像下面所示

UIGraphicsBeginImageContext(CGSizeMake(145.0,145.0));

[takephoto.layer renderInContext:UIGraphicsGetCurrentContext()]; 

UIImage *LargeImage = UIGraphicsGetImageFromCurrentImageContext(); 

UIGraphicsEndImageContext(); 

NSData *data = UIImageJPEGRepresentation(LargeImage, 0.25); 

NSString *strImageFinalBASE64 =[data base64Encoding]; 

takePhoto可以成爲你的UIImageView:

IBOutlet中的UIImageView * takephoto;

+0

謝謝,但它不能解決損壞的圖像問題... – Yos 2010-11-30 16:00:24