下载文件到特定的位置与Response.BinaryWrite和使用Server.Mappath可能? [英] download file to a specific location with Response.BinaryWrite and Server.Mappath possible?

查看:679
本文介绍了下载文件到特定的位置与Response.BinaryWrite和使用Server.Mappath可能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据库中的文件关联varbinary数据。这是code我使用上下载点击一个链接文件 -

I have varbinary data associated with a file in the DB. This is the code I'm using to download this file on clicking a link -

//a is my attachment object
var r = context.Response;
r.AddHeader("Content-Disposition", "attachment; filename=" + a.FileName);
r.Charset = "";
r.ContentType = a.MIME;   
r.BinaryWrite(a.Content.ToArray());

目前,这个文件被下载到Downloads文件夹。有什么办法在那里创建了用户系统中的新文件夹,这个文件下载?我读使用Server.Mappath 可以r.WriteFile使用,但我不能肯定。可以这样做?

Currently, this file gets downloaded to the Downloads folder. Is there any way to create a new folder in the users system and have this file download there? I read that server.mappath can be used with r.WriteFile, but I'm not quite sure. Can this be done?

推荐答案

没有,这是不可能的。否则,人们可以编写恶意文件的所有方式将特定的系统目录。一旦你发送文件到用户,控制现在是伸出你的双手。

No, this is not possible. Otherwise, people could maliciously write all manner of files into specific system directories. Once you send the file down to the user, the control is now out of your hands.

这篇关于下载文件到特定的位置与Response.BinaryWrite和使用Server.Mappath可能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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