下载时重命名文件 [英] rename file on download

查看:76
本文介绍了下载时重命名文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网站上,我有一个动态链接(aspx)到这个文件0AX120S.jpg(隐私

保护)。当访问者点击链接时我希望他们看到

my_vacation_pic.jpg(从数据库中获取realname)是否可以使用

ASP.NET(C#)?


谢谢


Aaron

On my website I have a dynamic link(aspx) to this file 0AX120S.jpg(privacy
protection). When a visitor clicks on the link I want them to see
my_vacation_pic.jpg (fetch realname from database) is this possible with
ASP.NET(C#)?

Thanks

Aaron

推荐答案

当然是,


0AX120S可能是您表中的主键,它将包含另一列中真实文件名的

链接。使用SQL从数据库中查询文件名



" Aaron" <ク***** @ yahoo.com>写了留言

新闻:嗯************** @ tk2msftngp13.phx.gbl ...
Yeah of course,

0AX120S could be your primary key in your table and it would include the
link for the real filename in another column. Use SQL to query the filename
from the database.
"Aaron" <ku*****@yahoo.com> wrote in message
news:um**************@tk2msftngp13.phx.gbl...
在我的网站上我有一个动态链接(aspx)到这个文件0AX120S.jpg(隐私
保护)。当访问者点击链接时我希望他们看到
my_vacation_pic.jpg(从数据库中获取realname)是否可以使用
ASP.NET(C#)?

谢谢

Aaron
On my website I have a dynamic link(aspx) to this file 0AX120S.jpg(privacy
protection). When a visitor clicks on the link I want them to see
my_vacation_pic.jpg (fetch realname from database) is this possible with
ASP.NET(C#)?

Thanks

Aaron



但是当实际文件名为

时,如何将文件输出为my_vacation_pic.jpg $ 0 $ b)用户点击此链接
http://mywebsite.com/download.aspx?file=003

2)download.aspx从数据库中获取索引003

3)输出0AX120S.jpg为my_vacation_pic.jpg

4)用户只知道他下载my_vacation_pic.jpg


我为什么要这样做?好吧,用户可以将文件上传到我的服务器,并且我希望它们只能通过download.aspx脚本下载。它还可以帮助保护服务器免受人们上传的恶意脚本的攻击。<​​br />

谢谢



Tampa.NET Koder <一个******* @ microsoft.com>在消息中写道

news:ub ************** @ TK2MSFTNGP10.phx.gbl ...
But how do I output the file as my_vacation_pic.jpg when the actual filename
stored on the server is 0AX120S.jpg

1)the user clicks this link
http://mywebsite.com/download.aspx?file=003
2)download.aspx fetch index 003 from database
3)outputs 0AX120S.jpg as my_vacation_pic.jpg
4)the user only knows that hes downloading my_vacation_pic.jpg

Why do I want to do this? well, the user can upload files to my server and i
want them to be downloadable only through the download.aspx script. It also
helps protect the server against malicious scripts that people upload.

Thanks


"Tampa.NET Koder" <an*******@microsoft.com> wrote in message
news:ub**************@TK2MSFTNGP10.phx.gbl...
是的,当然,

0AX120S可能是您表中的主键,它将包含另一列中真实文件名的
链接。使用SQL从数据库中查询
文件名。

" Aaron" <ク***** @ yahoo.com>在消息中写道
新闻:嗯************** @ tk2msftngp13.phx.gbl ...
Yeah of course,

0AX120S could be your primary key in your table and it would include the
link for the real filename in another column. Use SQL to query the
filename from the database.
"Aaron" <ku*****@yahoo.com> wrote in message
news:um**************@tk2msftngp13.phx.gbl...
在我的网站上我有一个动态链接( aspx)到这个文件
0AX120S.jpg(隐私保护)。当访问者点击我想要的链接时,他们看到my_vacation_pic.jpg(从数据库中获取realname)是否可以使用ASP.NET(C#)?

谢谢

Aaron
On my website I have a dynamic link(aspx) to this file
0AX120S.jpg(privacy protection). When a visitor clicks on the link I want
them to see my_vacation_pic.jpg (fetch realname from database) is this
possible with ASP.NET(C#)?

Thanks

Aaron




2005年2月19日星期六12:55:54 -0700, ;亚伦" <ク***** @ yahoo.com>写道:
On Sat, 19 Feb 2005 12:55:54 -0700, "Aaron" <ku*****@yahoo.com> wrote:
但是当存储在服务器上的实际文件名为0AX120S.jpg
But how do I output the file as my_vacation_pic.jpg when the actual filename
stored on the server is 0AX120S.jpg


时,如何将文件输出为my_vacation_pic.jpg br />
嗨Aaron:


一种方法是使用设置图像标签的src属性来

一个ASPX页面,并让ASPX页面确定正确的文件名为

使用并将jpeg内容写回响应。


这是一个例子:
http://msdn.microsoft.com /msdnmag/is...e/default.aspx


希望这会有所帮助,


-

Scott
http://www.OdeToCode.com/ blogs / scott /


这篇关于下载时重命名文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆