上传控件(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();

posted @ 2012-04-12 15:27  ゞ追忆o0ゞ  阅读(1324)  评论(0编辑  收藏  举报