How to upload image that was taken from UIImagePickerController

后端 未结 6 909
离开以前
离开以前 2020-12-17 04:41

After user choose image from the iPhone library with UIImagePickerController, I want to upload it to my server using ASIHTTPRequest library.

6条回答
  •  不思量自难忘°
    2020-12-17 04:47

    Save the photo in Document directory and use that url to upload.For example

    NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Test.jpg"];
    [UIImageJPEGRepresentation(img, 1.0) writeToFile:jpgPath atomically:YES];
    

    upload this image as [request setFile:jpgPath forKey:@"image"];

提交回复
热议问题