通过从iphone浏览file upload和发送文件

我正在制作一个应用程序,用户可以在该应用程序中聊天,也可以从该应用程序发送文件 但我坚持的地步,用户可以通过附件发送任何文件给其他用户,但我没有find任何示例应用程序或帮助代码,所以任何人都可以帮助我解决我的问题。

告诉我一些示例应用程序链接,以及通过使用应用程序从iPhone浏览来上传和发送文件的技术。

一些build议,以实现这一点

浏览

上传

让我先给你一些build议,就像这样从设备上传文件

1。

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { NSString *mediaType = info[UIImagePickerControllerMediaType]; if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) { // Media is an image picImage = [info objectForKey:UIImagePickerControllerOriginalImage]; NSString *imagePath = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"Documents/image.jpg"]]; filePath = imagePath; [UIImageJPEGRepresentation(picImage, 1.0) writeToFile:imagePath atomically:YES]; arrayMute = (NSMutableArray*) [self sendData:filePath] } } 

2现在只需通过ASIFormDataRequest将媒体上传到webservices,然后他们将生成链接返回到链接。 那么你可以通过xmpp将该链接发送给另一个用户。 然后其他用户可以下载该媒体。

 -(NSMutableArray*)sendData:(NSString*)multiMData { ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:@"http://194.158.1.25/IphoneVideoService/webservice.asmx/GetData1"]]; [request addRequestHeader: @"Content-Type" value: @"application/x-www-form-urlencoded"]; [request setDelegate:self]; [request setDidFailSelector:@selector(uploadFailed:)]; [request setUploadProgressDelegate:progressToDownload]; [request setDidFinishSelector:@selector(uploadFinished:)]; [request setDidFinishSelector:@selector(requestFailed:)]; [request setDidFinishSelector:@selector(requestFinished:)]; [request setShouldContinueWhenAppEntersBackground:YES]; NSString *url = [[NSURL fileURLWithPath:multiMData] path]; [request setFile:url withFileName:[NSString stringWithFormat:@"Hello.jpeg"] andContentType:@"image/jpeg" forKey:@"file"]; [request setTimeOutSeconds:50000]; [request setRequestMethod:@"POST"]; [request startSynchronous]; SBJSON *sbJason = [[SBJSON alloc] init]; NSMutableArray *getUploadArray = [sbJason objectWithString:responseForMedia]; return getUploadArray; }