ios 上传图片base64 demo
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ios 上传图片base64 demo相关的知识,希望对你有一定的参考价值。
- (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的主要内容,如果未能解决你的问题,请参考以下文章