第三方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"& ...
随机推荐
- asp.net 5 中应用程序根目录及物理文件根目录的获取方式 此文已过期,不再适应rc1以后的版本
之前看了asp.net5,小弟就试着用了用,做了个小网站练习一下,有一个小模块需要上传图片到wwwroot下的images文件夹,但是aspnet5 发生了翻天复地变化,之前获取网站根目录的的方法不再 ...
- linux命令每日一练习 解压命令
.tar 解包:tar xvf FileName.tar打包:tar cvf FileName.tar DirName(注:tar是打包,不是压缩!)———————————————.gz解压1:gun ...
- linux命令每日一练习 创建新文件 列出文件的时候带着行号
touch ××× nl ****
- 【转】Nginx中upstream有以下几种方式:
1.轮询(weight=1) 默认选项,当weight不指定时,各服务器weight相同, 每个请求按时间顺序逐一分配到不同的后端服务器,如果后端服务器down掉,能自动剔除.upstream bak ...
- 010-Scala单例对象、伴生对象实战详解
010-Scala单例对象.伴生对象实战详解 Scala单例对象详解 函数的最后一行是返回值 子项目 Scala伴生对象代码实战 object对象的私有成员可以直接被class伴生类访问,但是不可以被 ...
- Ubuntu下freeradius的EAP-MD5,PEAPv0/EAP-MSCHAPv2,EAP-TTLS/MD5,EAP-TTLS/MSCHAPv2方式认证(基于mysql)
基于freeradius+mysql,今天验证下freeradius的EAP认证:1.EAP-MD5:2.EAP-PEAP 一.EAP-MD5方式认证 1.修改配置文件 (1)/usr/local/e ...
- Dapper学习笔记(4)-事务
Dapper中对事务的处理也非常简单,如下代码所示: private void DapperTransaction() { using (IDbConnection con = OpenConnect ...
- 解决PyScripter中文乱码问题
环境: PyScripter 2.6.0.0 python3.4 问题: PyScripter有个小坑,打开文件后中文都成了乱码.在PyScripter中新建的文件中文可以正常显示,但是重新打开后中文 ...
- Hadoop原理介绍
Hadoop核心之HDFS 架构设计 老嗨 2015-09-18 16:55:00 浏览225 评论0 摘要: 概述:HDFS即Hadoop Distributed File System分布式文 ...
- android 内存查看的不同数据指标
内存耗用:VSS/RSS/PSS/USS 的介绍 VSS - Virtual Set Size 虚拟耗用内存(包含共享库占用的内存) RSS - Resident Set Size 实际使用物理内存( ...