IOS Get image name in Image Picker ViewConroller

Get the name of the chosen image 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];
    NSLog(@"image name %@",imageName);

}

Here imageName variable will contains the name of the file chosen.

Related Posts

DOWNLOAD OUR APP AND NEVER MISS THE DAILY UPDATES

Get all the updates on your mobile. Participate in our giveaways and get exclusive deals and offers.

TechRounder App

2 thoughts on “IOS Get image name in Image Picker ViewConroller”

  1. Thanks Vipin,
    This solution helps me in swift. I have used the same concept in swift to get the filename.
    In Swift it works like:-
    func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {

    let gotImage = info[UIImagePickerControllerOriginalImage] as! UIImage
    let imagePath: NSURL = (info[UIImagePickerControllerReferenceURL] as! NSURL)
    let imageName: String = imagePath.lastPathComponent!
    print(imageName)
    self.dismissViewControllerAnimated(true, completion: nil)
    }

    Reply

Leave a Comment

Share via
Copy link
We would like to show you notifications for the latest offers and updates.
Dismiss
Allow Notifications