上传控件(input type="file")的用法

//判断上传的文件是否为空
HttpPostedFile postFile = Request.Files["upfile"];
if (postFile == null || postFile.ContentLength < 0)
{

    //提示为空或者其他操作 

//如果是文本文件,读取其内容
Stream s = StreamCopyTo(postFile.InputStream);
StreamReader sr = new StreamReader(s, System.Text.Encoding.Default);
strCode = sr.ReadToEnd(); //strCode就是文本文件中的内容
s.Close();

原文地址:https://www.cnblogs.com/zhuiyi/p/2444068.html