我做了一个iphone 应用程序上传音频文件。
我还在Asp.net中制作了Webervices, 支持这个应用程序的其他功能, 并在Goodddy服务器上公布。
我要从我的iphone 应用程序上上传/ 保存服务器上的音频文件 。
我搜索过许多代码,但并不相关,也没有用处。
我该怎么做?
如何获得服务器路径, 我们可以上传文件?
请提供一些窃听器的样本代码。
我做了一个iphone 应用程序上传音频文件。
我还在Asp.net中制作了Webervices, 支持这个应用程序的其他功能, 并在Goodddy服务器上公布。
我要从我的iphone 应用程序上上传/ 保存服务器上的音频文件 。
我搜索过许多代码,但并不相关,也没有用处。
我该怎么做?
如何获得服务器路径, 我们可以上传文件?
请提供一些窃听器的样本代码。
这就是 IPOST 网络服务文件( 可以是任何文件、 图像、 视频、 音频、 视频、 任何音频) 的方式
NSString *fileName = @"myAudio";
NSData *audioFile = [NSData dataWithContentsOfFile:@"myAudio.ext"]; //some audio
NSString *urlString = @"http://www.something.com/someservice";
urlString = [urlString stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
NSURL *url = [NSURL URLWithString:urlString];
NSString *strPostLength = [NSString stringWithFormat:@"%d", [audioFile length]];
NSMutableURLRequest *uRequest = [[NSMutableURLRequest alloc] init];
[uRequest setURL:url];
[uRequest setHTTPMethod:@"POST"];
if (audioFile)
{
NSMutableData *body = [NSMutableData data];
NSString *boundary = [NSString stringWithString:@"---------------------------14737809831466499882746641449"];
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary];
[uRequest addValue:contentType forHTTPHeaderField: @"Content-Type"];
/*
now lets create the body of the post
*/
[body appendData:[[NSString stringWithFormat:@"
--%@
",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[uRequest setValue:strPostLength forHTTPHeaderField:@"Content-Length"];
[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name="userfile"; filename="%@.ext"
",fileName] dataUsingEncoding:NSUTF8StringEncoding]];
/ 用户文件 - & gt; 服务器代码中给出的变量名称...
[body appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream
"] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[NSData dataWithData:audioFile]];
[body appendData:[[NSString stringWithFormat:@"
--%@--
",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
// setting the body of the post to the reqeust
[uRequest setHTTPBody:body];
}
NSURLConnection *uConn=[[NSURLConnection alloc] initWithRequest:uRequest delegate:self];
if (uConn)
{
NSLog(@"Failed to connect to url");
}
uRequest = nil;
我希望这能帮助你 解决你的问题...
I am tring to retrieve a filename or the file itself for use in a java servlet (from a web form). I have a file form field: <form enctype="multipart/form-data" method="post" action="...
I have several applications that allow users to upload attachments that are stored inside a database table. This has worked fine for several years because it was initially intended for smallish image ...
I want to implement Asynchronus File Upload. I ve tried ajax:AsyncFileUpload control. It s working fine only with InProc Mode. But I m using StateServer Mode. Any help from anybody? Thanks in ...
I am just playing around and trying to make a very simple CMS. Right now I what I do right now is I use "FtpWebRequest" to get the file that they want to change around and stick it into a jquery ...
Howdy - I ve written a very simple app to accept job applications including a resume upload. Running the bundled server for development locally, I can successfully upload files via the web form on ...
I have installed filebrowser for Django (not filebrowser3) and when I try to upload a file I recieve the following error: 403 Forbidden CSRF verification failed. Request aborted. More ...
I would like to to create a 2-step file uploader: Open dialog. Select one file from computer. I would like to eliminate the step where the user must submit the form, and instead do it automatically ...
How can I set the value of this? <input type="file" />