如何使用 Objective C 中的 ASIHttpRequest 将文件上传到服务器并使用 asp 文件接收?

发布于 2024-12-13 10:06:41 字数 1131 浏览 0 评论 0原文

我需要将图像文件上传到我的服务器,因为我已经在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风苍溪 2024-12-20 10:06:41

您应该标记您的问题 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文