上传控件(input type="file")的用法
2012-04-12 15:27
267 查看
//判断上传的文件是否为空
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();
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();
相关文章推荐
- 如何设置上传文件控件 input type="file" 的 默认值
- 【翻译】Styling an input type="file"美化文件上传控件
- IE and FireFox使用JavaScript清空上传控件input type="file"
- 后台处理客户端控件上传的文件(input type="file")
- JS清空上传控件input(type="file")的值的代码第1/2页
- 使用JS清空上传控件input(type="file")的值
- input file控件限制上传文件类型 网页上添加一个input file HTML控件: 1 <input id="File1" type="file" /> 默认是这样的,所有文件类
- 清空上传控件<input type="file" />的值
- html的文件控件<input type="file">样式的改变
- angularjs上传 和 <input type="file">与ng-model 的玩法
- 自定义 input type="file" 文件上传样式
- html input控件type为file上传文件、图片,及保存为原文件
- js 实现 input type="file" 文件上传示例代码
- 更改上传文件的样式<input type="file>
- 上传按钮样式优化 <input type="file" />
- jquery如何获取input(file)控件上传的图片名称,即"11111.jpg"
- js 实现 input type="file" 文件上传示例代码
- <input type="file">更改 页面显示 浏览 为上传 .
- asp.net/c# 用<input type="file" />实现文件上传,multipart/form-data