IOS Get image URL in Image Picker ViewConroller

Get the path of the image chosen from library using the following code in using Image Picker ViewController

- (void)imagePickerController:(UIImagePickerController *)picker

        didFinishPickingImage:(UIImage *)img

                  editingInfo:(NSDictionary *)editingInfo{

    [picker dismissModalViewControllerAnimated:YES];
    NSURL *imagePath = [editingInfo objectForKey:@"UIImagePickerControllerReferenceURL"];
    NSString *imageName = [imagePath lastPathComponent];
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *localFilePath = [documentsDirectory stringByAppendingPathComponent:imageName];
    NSLog(@"localFilePath.%@",localFilePath);

}

Here localFilePath variable will contains the full image URL of the file chosen.

Sharing is caring!

Related Posts

Leave a Comment

DON’T MISS OUR GIVEAWAYS!
Subscribe To Newsletter
Subscribe to our newsletter and get all the latest updates offers and giveaways right in your inbox.
Subscribe
Give it a try, you can unsubscribe anytime.
close-link

Join Free Giveaway!

Subscribe to our newsletter to get latest offers and giveaways!
SUBSCRIBE
close-link
shares