2012-03-26 20 views
0

我正在錄製語音並將其保存到iphone文檔文件夾中,但我希望它將其上傳到服務器,那麼如何執行此操作?如何將iPhone文檔文件夾中的音頻文件上傳到服務器

NSString * path = [NSString stringWithFormat:@"%@/Documents/%@_%@_%@_%@.wav", NSHomeDirectory(), patient.firstName, patient.lastName, patient.transactionId, type]; 

其中,路徑是asset.path

if (assetIndex < ([assets count]-1)) { 
    while (assetIndex < ([assets count]-1)) { 
     assetIndex += 1; 
     Asset *asset = [assets objectAtIndex:assetIndex]; 
     NSData *data = [NSData dataWithContentsOfFile:asset.path]; 


    } 

回答

0

使用ASIHttpRequestjsonKit

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:kServerURLString]]; 
[request setData:imageData 
      withFileName:@"name.png" 
      andContentType:@"image/png" 
        forKey:@"file1"]; 
    [request setPostValue:@"yourJson" forKey:@"yourKey"]; 
    [request startSynchronous]; 
    NSError *localError = [request error]; 
    NSDictionary *responseDictionary = nil; 
    if(!localError){ 
     responseDictionary = [[request responseString] objectFromJSONString]; 
     NSLog(@"ResponseDict:%@",[responseDictionary description]); 
    }else{ 
     NSLog(@"Error:%@",[localError description]); 
    } 
0
+0

ü可以給我提供了一些代碼,這個鏈接,您提供它只是告訴使用異步。 – 2012-03-26 07:52:01

+0

從這裏獲取源http://stackoverflow.com/questions/8574053/how-can-i-upload-audio-file-to-server-in-iphone-application並從這裏http:// dip-upload。 blogspot.in/2011/04/upload-imageaudio-on-server-in-iphone.html – akk 2012-03-26 09:02:00

相關問題