Asp中上传文件

    

 string fileName = @"C:\Users\ITCA\Desktop\新建Excel.xlsx";
Response.Clear();

Response.ContentType = "application/excel";


FileInfo file = new FileInfo(fileName);

string name=HttpUtility .UrlEncode ("新建Excel");


Response.AddHeader("Content-Disposition", "attachment; filename="+name+".xlsx" );
Response.AddHeader("Content-Length", file.Length.ToString());


Response.WriteFile(fileName);
Response.End();

  设置响应报文 

   contentType

       报头

Response.AddHeader("Content-Disposition", "attachment; filename="+name+".xlsx" );            

显示文件大小  可以看到下载进度s

  Response.AddHeader("Content-Length", file.Length.ToString());

posted @ 2012-03-30 11:05  hhhker  阅读(359)  评论(0编辑  收藏  举报