码迷,mamicode.com
首页 > 移动开发 > 详细

ios 上传图片base64 demo

时间:2016-11-23 12:53:36      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:rar   odi   ref   post   ted   aspect   mode   anim   ima   

- (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

标签:rar   odi   ref   post   ted   aspect   mode   anim   ima   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!