input file 获取不到Request.Files 解决办法
? <input type="file"?name="xxxxxxx"/>必須有“name”屬性,否則在后臺代碼中用Request.Files是取不到值的
后臺讀取文件代碼:
HttpFileCollection httpFileCollection = HttpContext.Current.Request.Files;
??????????????? if (httpFileCollection.Count > 0)
??????????????? {
??????????????????? HttpPostedFile file = httpFileCollection[0];
???????????????????
???????????????????? StreamReader reader = new StreamReader(file.InputStream);
???????????????????? StringBuilder strLicense = new StringBuilder();
???????????????????? do
???????????????????? {
???????????????????????? strLicense.AppendLine(reader.ReadLine());
???????????????????? } while (!reader.EndOfStream);
???????????????????? return strLicense.ToString();
???????????????????
??????????????? }
轉載于:https://www.cnblogs.com/johnblogs/p/6709369.html
總結
以上是生活随笔為你收集整理的input file 获取不到Request.Files 解决办法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: hdu-4089-Activation-
- 下一篇: 信用卡不激活的后果