我在.doc,.docx,.pdf,.xls等上传文件夹中有不同的文件,我想在点击图片时下载文件。我从jquery值调用http泛型处理程序正确传递但不能正常工作
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileInfo.Name);
HttpContext.Current.Response.AppendHeader("Content-Length", fileInfo.Length.ToString());
HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.TransmitFile(fileInfo.FullName);
HttpContext.Current.Response.Flush();
答案 0 :(得分:0)
尝试这样的事情:
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + fileInfo.Name);
Response.AddHeader("Content-Length", fileInfo.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(fileInfo.FullName);
Response.End();
它应该有用!