iosswiftswift3uiimagepickercontroller

How can I get the image name when selecting an image


I am working with images for the first time and I have been able to select an image and display it on the page. My question is how can I get the name of the image selected ? I been searching around but have not been able to find it . This code below fires every time you select an image

 func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any])
    {

        photoImageView.image = info[UIImagePickerControllerOriginalImage] as? UIImage
        self.dismiss(animated: false, completion: nil)
        let FileName = " Image Name of selected file"
    }

where the photoImageView is

var photoImageView = UIImageView(frame: CGRect(x: 82,y: 300,width: 100,height: 100))

a small ImageView that displays the selected image, I would like to get the FileName now any suggestions would be great


Solution

  • Short answer: You can't. The system doesn't give you the user's name for the file. I remember puzzling about this as well.

    As I recall what it gives you is a pointer to an in-memory UIImage object, not even a URL to a system-named file on disk. (But it's been a while since I've used the image picker.)