Possible Duplicate:
how to upload a audio file from iphone documents folder to server
I have path where is sound file in app which i record i want to send it to server how may send this i have send image upload to server but how may i send from documets folder to server
This is the path where my files is
NSString * path = [NSString stringWithFormat:@"%@/Documents/%@_%@_%@_%@.wav", NSHomeDirectory(), theCellData.firstName,theCellData.lasttName, type];
So may use this to upload that file to server I am uploading image from resources in this way
UIImage*myImage=[UIImage imageNamed:@"dr.jpg"];
imageView.image=myImage;
NSData *imageData = UIImageJPEGRepresentation(imageView.image, 1.0);
// setting up the URL to post to
NSString *urlString = @"http://www.celeritas-solutions.com/emrapp/emr.php";
// setting up the request object now
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:@"POST"];
NSString *boundary = [NSString stringWithString:@"---------------------------14737809831466499882746641449"];
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary];
[request addValue:contentType forHTTPHeaderField: @"Content-Type"];
NSMutableData *body = [NSMutableData data];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name=\"userfile\"; filename=\"dr.jpg\"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[NSData dataWithData:imageData]];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:body];
// now lets make the connection to the web
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
NSLog(returnString);
PHP Code
iPhone Code: