Tag: 多部分

Multipart / Formdata图片上传,获取文件

在我的应用程序中,我想上传一个通过UIImagePickerControllerselect的图像到只接受JPEG图像的数据库。 我在这里浏览了许多问题,在其他论坛上,但我仍然没有得到它的工作。 我希望你能检查我的代码,如果有一个我看不见的错误。 这是上传的完整方法,包含图片说明,图片标题和此图片的地理数据: – (void) uploadPic{ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *destinationFilePath = [[NSString alloc] initWithFormat: @"%@/%@.jpeg", documentsDirectory, self.chosenImage.imgTitle]; NSURL *fileURL = [[NSURL alloc]initWithString:destinationFilePath]; NSLog(@"will upload file: %@", destinationFilePath); NSData *imageURLdata = [[NSData alloc]initWithContentsOfURL:fileURL]; (*1) NSData *imageData = UIImageJPEGRepresentation(self.chosenImage, 90); (*2) //Here i tried 2 ways of […]