<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();
}