版权声明:本文为博主原创文章,未经博主允许不得转载。 https://cloud.tencent.com/developer/article/1338161
{
NSData * imageData = UIImagePNGRepresentation(tempImage);
NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString * documentsDirectory = paths objectAtIndex:0;
// Now we get the full path to the file
NSString * fullPathToFile = documentsDirectory stringByAppendingString:imageName;
// and then we write it out
imageData writeToFile:fullPathToFile atomically:NO;
// NSLog(@"路径:%@", NSHomeDirectory() stringByAppendingPathComponent:@"Documents1.png");
// 将存入到沙盒的图片再取出来,目的是为了进行上传
NSLog(@"fullPathToFile:%@", fullPathToFile);
NSString * path = fullPathToFile;
// 二进制的数据就可以进行上传
NSData * data = NSData dataWithContentsOfFile:path;
UIImage * image = UIImage imageWithData:data;
self.postImage.image = image;
}