I want to take a photo or pick a picture from iphoto library and then upload it to webserver. Use imagePickerController I can only get a UIImage Object,I can't know it's file path or file type(png,jpg,etc.). I have google for a long time but still can't find a solution. Any one can help me? Thank You!
Asked
Active
Viewed 260 times
1 Answers
0
You need to get the raw data from the image. Take a look at questions like this one.
Then, just set the appropriate MIME type on your http request and shoot the data up to the server.
-
I have tried that way and upload image to server successfully.But first I need to know the file type before use UIImageJPEGRepresentation or UIImagePNGRepresentation. Cause in photo library there are png image and jpg image. – logan Aug 10 '11 at 01:42
-
I have found the way to get the file extension,in function,imagePickerController:didFinishPickingMediaWithInfo:,we can use [info objectForKey:UIImagePickerControllerReferenceURL],it like assets-library://asset/asset.JPG?id=1000000002&ext=JPG". so that is a JPG file. Thank You! – logan Aug 10 '11 at 03:19