首页 > 移动平台 > 详细

ios 上传图片base64 demo

时间:2016-11-23 12:50:31      阅读:527      评论:0      收藏:0      [点我收藏+]

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{

    //1.获取当前选中相册的照片

    UIImage * image = [info objectForKey:UIImagePickerControllerOriginalImage];

           //1.1创建一个imageview属性,显示图片,将imageview(Mode)改成(Aspect Fit)

             self.userImage.image = image;

    //2.获取图片名字

             //:想要用到以下操作,需要引入以下的内容

            //#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修改头像

        [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图片转成Base64字符串:

    NSData *data = UIImageJPEGRepresentation(image, 1.0f);

    NSString *encodedImageStr = [data base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];

    

    //2.3发起请求

}

iOS 图片转成base64编码

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

获取透过UIImagePackerController获取的系统相册图片的名称信息及保存系统相册到本地

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

ios 上传图片base64 demo

原文:http://www.cnblogs.com/Ruby_c/p/6092921.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!