how to get the path of the image which is in iphone gallery

前端 未结 2 1242
谎友^
谎友^ 2021-02-10 23:42

i need to upload a image from iphone gallery ,but i am not getting the path of the picked image (using image picker)

in the image picke

2条回答
  •  心在旅途
    2021-02-11 00:20

    May be it will helpful for u

    [picker dismissModalViewControllerAnimated:YES];
    imageView.image= [info objectForKey:@"UIImagePickerControllerOriginalImage"];
    NSData *webData = UIImagePNGRepresentation(imageView.image);
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *localFilePath = [documentsDirectory stringByAppendingPathComponent:png];
    [webData writeToFile:localFilePath atomically:YES];
    NSLog(@"localFilePath.%@",localFilePath);
    
    UIImage *image = [UIImage imageWithContentsOfFile:localFilePath];
    

提交回复
热议问题