如何使用 Objective C 中的 ASIHttpRequest 将文件上传到服务器并使用 asp 文件接收?
我需要将图像文件上传到我的服务器,因为我已经在 Objective-C (Mac OS X 应用程序)中完成了一些编码。 这是我的代码:
-(IBAction)upLoadFilesToServer:(id)sender
{
[networkQueue reset];
[networkQueue setDelegate:self];
[networkQueue reset];
[networkQueue setShowAccurateProgress:YES];
[networkQueue setUploadProgressDelegate:myProgressIndicator];
[networkQueue setRequestDidFailSelector:@selector(UploadingFailed:)];
[networkQueue setRequestDidFinishSelector:@selector(uploadCompleted:)];
[networkQueue setDelegate:self];
ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:@"http://122.166.124.229/BALMWebServiceIOS/bin/"]] autorelease];
[request setPostValue:@"test" forKey:@"value1"];
[request setPostValue:@"test" forKey:@"value2"];
[request setPostValue:@"test" forKey:@"value3"];
[request setUploadProgressDelegate:myProgressIndicator];
[request setFile:@"/Users/administrator/Desktop/6.jpeg" forKey:@"file"];
[networkQueue addOperation:request];
[networkQueue go];
}
现在我需要从服务器接收这个文件。虽然在谷歌中搜索大多数示例都是使用 php 文件完成的,但我不想通过 php 文件来完成。是否可以通过 .asp 文件或任何其他文件来完成文件?如果可能的话我该怎么做?
谢谢, 哈丁
I need to upload a image file to my server for that i have done some coding in objective-c (mac os x application).
Here is my code:
-(IBAction)upLoadFilesToServer:(id)sender
{
[networkQueue reset];
[networkQueue setDelegate:self];
[networkQueue reset];
[networkQueue setShowAccurateProgress:YES];
[networkQueue setUploadProgressDelegate:myProgressIndicator];
[networkQueue setRequestDidFailSelector:@selector(UploadingFailed:)];
[networkQueue setRequestDidFinishSelector:@selector(uploadCompleted:)];
[networkQueue setDelegate:self];
ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:@"http://122.166.124.229/BALMWebServiceIOS/bin/"]] autorelease];
[request setPostValue:@"test" forKey:@"value1"];
[request setPostValue:@"test" forKey:@"value2"];
[request setPostValue:@"test" forKey:@"value3"];
[request setUploadProgressDelegate:myProgressIndicator];
[request setFile:@"/Users/administrator/Desktop/6.jpeg" forKey:@"file"];
[networkQueue addOperation:request];
[networkQueue go];
}
now i need to receive this file from server .while search in google most of the examples are done with php file i dont want to do it by php file.is it possible to do by .asp file or any other files?if it possible how can i do that?
Thanks,
Hardin
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该标记您的问题 ASP,因为 POST 如何到达服务器并不重要。
这里有一篇关于如何用asp接收文件的文章:
http://www.asp101.com/articles/jacob/scriptupload.asp
You should tag your question ASP, as there is no importance how the POST is coming to the server.
Here is an article on how to receive files with asp:
http://www.asp101.com/articles/jacob/scriptupload.asp