.net 最简单文件上传支持跨服务器

客户端HTML页面代码

<html>
<head>
    <meta http-equiv="content-type" content="text/html;charset=gb2312" />
    <title>File Upload</title>
</head>
<body>
    <form action="http://192.168.6.32:82/fileupload.aspx" method="post" id="uplodfile"
    name="uploadfile" enctype="multipart/form-data">
    <input type="file" id="file" name="upload" style="width: 300px" />
    <input name="submit" type="submit" value="OK" />
    </form>
</body>
</html>

 

 

.Net 接收文件代码fileupload.aspx

 

 protected void Page_Load(object sender, EventArgs e)
        {
            string filepath = @"E:\ImgToStream\imgs\";
            HttpPostedFile files = Request.Files["upload"];
            if (files != null && files.ContentLength > 0)
            {
                string filename = System.IO.Path.GetFileName(files.FileName); //获取文件名
                files.SaveAs(filepath + filename);
            }
        }

 

posted @ 2012-04-17 13:29  晓风拂月  阅读(603)  评论(0编辑  收藏  举报