Search code examples
iphoneipaduiimagepickercontrollerphotolibrary

uiimagepickercontroller - get the name of the image selected from photo library


I am trying to upload the image from my iPhone/iPod touch to my online repository, I have successfully picked the image from Photo Album but i am facing one problem i want to know the name of the image such as image1.jpg or some thing like that. How i would know the name of the picked image.


Solution

  • I guess knowing the exact image name would not be an issue rather getting a unique name for the picked image would solve your purpose so that you can upload the image on server and track it via its name. May be this can help you

    NSMutableString *imageName = [[[NSMutableString alloc] initWithCapacity:0] autorelease];
    
    CFUUIDRef theUUID = CFUUIDCreate(kCFAllocatorDefault);
    if (theUUID) {
        [imageName appendString:NSMakeCollectable(CFUUIDCreateString(kCFAllocatorDefault, theUUID))];
                CFRelease(theUUID);
    }
    [imageName appendString:@".png"];
    

    After you pick the image from Picker you can generate a unique name and assign it to the Picked image. Cheers