如何将文件上传到Web服务器(用C#编写) [英] How to upload files to Web Server (written in C#)

查看:66
本文介绍了如何将文件上传到Web服务器(用C#编写)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,世界!



我用C#编写了一个(GUI)Web服务器。我可以访问索引文件并从服务器下载(或流)文件。但我不能上传到服务器,因为我不能写任何代码到POSTRequest()接受上传文件到服务器 - 我没有想法。





Hello, world!

I programmed a (GUI) Web Server in C#. I can access the index file and download (or stream) files from server. But I can''t upload to Server because I can''t write any code to POSTRequest() to accept uploading files to Server - I''m out of ideas.


if (Type.ToUpper() == "GET ") // IF THERE IS GET REQUEST
{
     GETRequest(buffer, Client); // private void GETRequest() code works OK
}


if (Type.ToUpper() == "POST") // IF THERE IS POST REQUEST
{
     POSTRequest(buffer, Client); // private void POSTRequest() -empty, have no ideas what to write here...
}









有人可以帮我写一篇文章C#中的代码(到服务器)接受从HTML上传文件





谢谢!





Can someone help me and write a piece of code in C# (to Server) to accept uploading files from HTML


Thanks!

推荐答案

正如我所说,你可以找到大量的代码示例。例如:

http://msdn.microsoft.com/en-us /library/aa479405.aspx [ ^ ]。



这个可能是最简单的,也是最接近它的基础: http://stackoverflow.com/questions/569565/uploading-files-in-asp-net-without -using-the fileupload-server-control [ ^ ]。



另请参阅此CodeProject文章:使用ASP.NET上传文件 [ ^ ]。



你觉得冷得多了。



-SA
As I say, you could find huge number of code samples. For example:
http://msdn.microsoft.com/en-us/library/aa479405.aspx[^].

This one is probably the simplest, and the closest to the basics of it: http://stackoverflow.com/questions/569565/uploading-files-in-asp-net-without-using-the-fileupload-server-control[^].

See also this CodeProject article: File Upload with ASP.NET[^].

You cold find a lot more.

—SA


这篇关于如何将文件上传到Web服务器(用C#编写)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆