2010-11-29 129 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