第三方Girdview中文件下载的方法,以及js显示图片

/// <summary>
/// 文件下载事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid_OnCopyInsertClick(object sender, EventArgs e) {
LinkButton LBut = sender as LinkButton;
string sellContractScanId = LBut.CommandName;
string url = "";
string name = "";
foreach (DataRow dr in griViewTable.Rows) {
if (dr["序号"].ToString().Equals(sellContractScanId)) {
url = dr["路径"].ToString();
name = dr["文件名称"].ToString();
break;
} }
if (System.IO.File.Exists(HttpContext.Current.Server.MapPath(url))) {
Response.Redirect("UserInfoScanDownload.aspx?FilePath=" + url + "&FileName=" + name);
}
else
{ bp.Alert("文件不存在!");
}
BasePage bp = null;
protected void Page_Load(object sender, EventArgs e) {
if (Request["FilePath"] == null)
return;
if (Request["FileName"] == null)
return;
string fileRpath = Request["FilePath"].ToString();
string fileName = Request["FileName"].ToString();
if (System.IO.File.Exists(HttpContext.Current.Server.MapPath(fileRpath))) {
Response.ClearHeaders();
Response.Clear();
Response.Expires = 0;
Response.Buffer = true;
Response.AddHeader("Accept-Language", "zh-tw");
string name = System.IO.Path.GetFileName(fileRpath);
System.IO.FileStream files = new FileStream(HttpContext.Current.Server.MapPath(fileRpath), FileMode.Open, FileAccess.Read, FileShare.Read); byte[] byteFile = null;
if (files.Length == 0) {
byteFile = new byte[1];
}
else
{
byteFile = new byte[files.Length];
}
files.Read(byteFile, 0, (int)byteFile.Length);
files.Close();
Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); Response.ContentType = "application/octet-stream;charset=gbk";
Response.BinaryWrite(byteFile);
Response.End();
}
}
第三方Girdview中文件下载的方法,以及js显示图片的更多相关文章
- ubuntu下使用PIL中的show函数,无法显示图片的问题
问题描述:ubuntu14.04系统,python2.7(version),正在学习python中, from PIL import Image im = Image.open('1.jpg') im ...
- PHP中的__toString方法(实现JS里的链式操作)
_toString方法是在打印对象时自动调用的魔术方法,如果不声明会报以下错 Catchable fatal error: Object of class String could not be co ...
- MVC发布后项目存在于根目录中的子目录中时的css与js、图片路径问题
加载固定资源js与css <script src="@Url.Content("~/Scripts/js/jquery.min.js")" type=&q ...
- JS与OC交互,JS中调用OC方法(获取JSContext的方式)
最近用到JS和OC原生方法调用的问题,查了许多资料都语焉不详,自己记录一下吧,如果有误欢迎联系我指出. JS中调用OC方法有三种方式: 1.通过获取JSContext的方式直接调用OC方法 2.通过继 ...
- iOS之在webView中引入本地html,image,js,css文件的方法 - sky//////////////////////////////////////ZZZZZZZZZZZZZZZ
iOS之在webView中引入本地html,image,js,css文件的方法 2014-12-08 20:00:16CSDN-sky_2016-点击数:10292 项目需求 最近开发的项 ...
- js中的tostring()方法
http://blog.sina.com.cn/s/blog_85c1dc100101bxgg.html js中的tostring()方法 (2013-11-12 11:07:43) 转载▼ 标签: ...
- 秒味课堂Angular js笔记------Angular js中的工具方法
Angular js中的工具方法 angular.isArray angular.isDate angular.isDefined angular.isUndefined angular.isFunc ...
- js中继承的方法总结(apply,call,prototype)
一,js中对象继承 js中有三种继承方式 1.js原型(prototype)实现继承 代码如下: <SPAN style="<SPAN style="FONT-SIZE ...
- JS中通过call方法实现继承
原文:JS中通过call方法实现继承 讲解都写在注释里面了,有不对的地方请拍砖,谢谢! <html xmlns="http://www.w3.org/1999/xhtml"& ...
随机推荐
- http调接口
private static String doGetResult(String urlStr, Map<String, String> params) throws Exception ...
- wordpress 首页调用文章 不同样式的方法
<?php $count = 1; $display_categories = array(1); foreach ($display_categories as $category) { ?& ...
- one recursive approach for 3, hdu 1016 (with an improved version) , permutations, N-Queens puzzle 分类: hdoj 2015-07-19 16:49 86人阅读 评论(0) 收藏
one recursive approach to solve hdu 1016, list all permutations, solve N-Queens puzzle. reference: t ...
- VMware Workstation安装MAC OS X系统
http://jingyan.baidu.com/article/ff411625b9011212e48237b4.html
- MySQL正则表达式
正则表达式作用是匹配方本,将一个模式(正则表达式)与一个文本串进行比较. MySQL用WHERE子句对正则表达式提供了初步的支持,允许你指定用正则表达式过滤SELECT检索出的数据. MySQL仅支持 ...
- shell 随机从数组中抽取三个随机数(#可持续不停抽取)
#!/bin/bash #b= ]] #do #sleep 1 student=( DPL YPD LT ZZM HY CQW LSJ ybr) a=$[RANDOM%+] c=$[RANDOM%+] ...
- spring注解 @Transactional
一.@Transactional所需要的jar包 1.aopalliance.jar 这个包是AOP联盟的API包,里面包含了针对面向切面的接口.(通常Spring等其它具备动态织入功能的框架依赖此 ...
- C#和Java在重写上的区别
C# class A { public string Get1() { return "A1"; } public virtual string Get2() { return & ...
- OpenSSL 使用拾遗(二)---- X509 证书的 SKID/AKID 字段
SKID(证书使用者密钥标识符,subject key identifier 的简称)和 AKID(证书颁发机构密钥标识符,authority key identifier 的简称)是 X509 证书 ...
- JS第二天简单总结
布尔型变量:true,flase 广泛用于真假的逻辑判断 对象:分类,对象是由一些彼此相关的属性和方法集合在一起而构成的一个数据实体: 例如,var today = new Date();中,Date ...