iOS Uploading Pictures base64 demo

Source: Internet
Author: User

-(void) Imagepickercontroller: (uiimagepickercontroller *) Picker Didfinishpickingmediawithinfo: ( nsdictionary<nsstring *,ID> *) info{

//1. Get a photo of the currently selected album

UIImage * image = [info objectforkey:uiimagepickercontrolleroriginalimage];

//1.1 Create a ImageView property, display the picture, Change the ImageView (Mode) to (Aspect Fit)

self. Userimage. Image = image;

//2. get the picture name

Note : To use the following actions , you need to introduce the following content

#import <AssetsLibrary/ALAsset.h>

#import <AssetsLibrary/ALAssetsLibrary.h>

#import <AssetsLibrary/ALAssetsGroup.h>

#import <AssetsLibrary/ALAssetRepresentation.h></span>

nsurl *imageurl = [info valueforkey:uiimagepickercontrollerreferenceurl];

alassetslibraryassetforurlresultblock resultblock = ^ (alasset *myasset)

{

alassetrepresentation *representation = [Myasset defaultrepresentation];

nsstring *filename = [representation fileName];

self. Imgname = fileName;

sxlog(@ "FileName:%@",self. ) Imgname);

//2.1 Change your avatar

[self img_reqest: Image imgname: fileName];

};

2.2

alassetslibrary* assetslibrary = [[alassetslibrary alloc] init];

[Assetslibrary assetforurl: ImageURL resultblock: Resultblock failureblock:nil];

[self dismissviewcontrolleranimated:YES completion:nil];

}

-(void) Img_reqest: (UIImage *) image imgname: (nsstring *) imgname {

//2.1.1 UIImage picture turns into Base64 string:

nsdata *data = uiimagejpegrepresentation(image, 1.0f);

nsstring *encodedimagestr = [Data base64encodedstringwithoptions: Nsdatabase64encoding64characterlinelength];

2.3 Initiating a request

}

IOS images turn into base64 encoding

Http://www.cnblogs.com/ZGSmile/articles/5587226.html

Get the name information of the system album picture obtained through Uiimagepackercontroller and save the System album to the Local

Http://www.myexception.cn/operating-system/1833349.html

iOS Uploading Pictures base64 demo

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.