关于下载路径的隐藏都是通过传递一个数据库中的id,然后在另外一张页面通过传递的id在数据库中读出路径。
1、c#中实现的方法(只需要.aspx.cs的代码就可以了)
string sel_sql="select filevisualpath from tabmailattachfiles where fileid="+request.querystring["destfilename"].tostring();
// string destfilename = request.querystring["destfilename"]!=null?request.querystring["destfilename"]:"";
string destfilename=roa.components.fune_commerce.execad(sel_sql).tables[0].rows[0][0].tostring();
destfilename = server.mappath(".")+destfilename;
destfilename = server.urldecode(destfilename);
if(file.exists(destfilename))
{
fileinfo fi = new fileinfo(destfilename);
response.clear();
response.clearheaders();
response.buffer = false;
//response.appendheader("content-disposition","attachment;filename=" +httputility.urlencode(path.getfilename(destfilename),system.text.encoding.default));
response.appendheader("content-disposition","attachment;filename=" +httputility.urlencode(path.getfilename(destfilename),system.text.encoding.utf8));
response.appendheader("content-length",fi.length.tostring());
response.contenttype="application/octet-stream";
response.writefile(destfilename);
response.flush();
response.end();
}
else
{
response.write("<script langauge=javascript>alert('文件不存在!');history.go(-1);</script>");
response.end();
}
2、在asp中的实现方法
<!--#include file="conn.asp" -->
<%
response.buffer = true
response.clear
dim url
dim fso,fl,flsize
dim dname
dim objstream,contenttype,flname,isre,url1
'*********************************************调用时传入的下载文件名
m_id=trim(request.querystring("id"))
set rs=server.createobject("adodb.recordset")
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器