开发者

Problem uploading image on multi-part form via iPhone

I am trying to write an iPhone app that will allow me to upload a jpg via multi-part form.

Sometimes, the uploaded photo looks corrupted on the server with weird pixels and the photo looks cropped.

What could be the reason for that? How come I don't get a http error response from the server? (upload backend is written开发者_开发问答 in PHP)


You can use base64 encoding like shown below

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 can be your UIImageView:

IBOutlet UIImageView *takephoto;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜