开发者

Problem uploading image on multi-part form via iPhone

开发者 https://www.devze.com 2023-01-28 12:18 出处:网络
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.

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

精彩评论

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

关注公众号