如何从数据库创建文件并在浏览器中打开它们 [英] how create files from database and open them in browser

查看:94
本文介绍了如何从数据库创建文件并在浏览器中打开它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




想象一下以下情况:我有一个asp.net

应用程序,允许将文件上传到SQL Server

2000数据库(文件存储为类型images)。作为

下一步,我想实现一些方法来启用

从数据库下载这些文件,这导致我

到以下两个问题:

1.)如何在内存中创建文件?因为我不想

创建存储在我的网络服务器上的临时文件和

2.)我如何使用浏览器(使用
应用程序)相应地打开文件

扩展名?


感谢您的帮助。

祝你好运。

Daniel

解决方案

嗨丹尼尔,


||如何在内存中创建文件?因为我不想要
||创建存储在我的Web服务器上的临时文件


看看MemoryStreams - 内存中的文件:-)


System.IO.MemoryStream


问候,

Fergus


你好,


Daniel Walzenbach <哒********************** @ freudenberg.de> schrieb:

想象一下以下情况:我有一个asp.net
应用程序,允许将文件上传到SQL Server
2000数据库(文件存储为类型图像; )。作为下一步,我想实现一些方法来启用从数据库下载这些文件,这导致我面临以下两个问题:
1.)我怎样才能在内存中创建文件。因为我不想创建存储在我的Web服务器上的临时文件和


将数据加载到''MemoryStream''对象(名称空间''System。 IO'')。

2.)如何使用浏览器(使用
应用程序的人)根据他们的
扩展名打开文件?



我真的不明白你想做什么。你不能用浏览器打开每个文件

类型。


-

Herfried K. Wagner

MVP·VB Classic,VB.NET
http://www.mvps。 org / dotnet


您好,


感谢您的回答。

我想要实现的是一个页面,其中的文件表示为链接。如果

现在有人点击链接,应该有可能下载

文件和/或打开它(就像你下载时得到的对话一样。让

它是一个.doc文件,你的计算机会询问你是否要保存它/ b $ b或打开它。当你下载.exe文件时也是如此。如果你想保存或打开文件,你会被问到

。行为应该是相同的

,好像有人从文件服务器下载文件,但文件应该生成飞行的文件。在网络服务器的内存中(因为它来自

a SQL Server 2000)然后被发回,好像是下载一样。


再次感谢你的帮助。我很感激你的努力。


Daniel



" Herfried K. Wagner [MVP]" <喜******* @ m.activevb.de> schrieb im Newsbeitrag

新闻:#9 ************** @ TK2MSFTNGP12.phx.gbl ...

你好,

Daniel Walzenbach <哒********************** @ freudenberg.de> schrieb:

想象一下以下情况:我有一个asp.net
应用程序,允许将文件上传到SQL Server
2000数据库(文件存储为类型图像; )。作为下一步,我想实现一些方法来启用从数据库下载这些文件,这导致我面临以下两个问题:
1.)我怎样才能在内存中创建文件。因为我不想创建存储在我的网络服务器上的临时文件和



将数据加载到''MemoryStream''对象(命名空间''系统。 IO'')。

2.)我如何使用浏览器(使用
应用程序的人)根据他们的
扩展名打开文件?



我真的不明白你想做什么。你不能用浏览器打开每个文件类型。

-
Herfried K. Wagner
MVP·VB Classic,VB.NET
http://www.mvps.org/dotnet



Hi,

Imagine the following situation: I have an asp.net
application which allows uploading files to a SQL Server
2000 database (Files are stored as type "images"). As a
next step I would like to implement some way to enable
downloading those files from the database which leads me
to the following two problems:
1.) How can I create a file "in memory" as I don''t want to
create temporary files stored on my web server and
2.) How can I use the browser (of a person using the
application) to open the files accordingly to their
extensions?

Thank you for your help.
Best regards.
Daniel

解决方案

Hi Daniel,

|| How can I create a file "in memory" as I don''t want to
|| create temporary files stored on my web server

Take a look at MemoryStreams - files in memory :-)

System.IO.MemoryStream

Regards,
Fergus


Hello,

"Daniel Walzenbach" <da**********************@freudenberg.de> schrieb:

Imagine the following situation: I have an asp.net
application which allows uploading files to a SQL Server
2000 database (Files are stored as type "images"). As a
next step I would like to implement some way to enable
downloading those files from the database which leads me
to the following two problems:
1.) How can I create a file "in memory" as I don''t want to
create temporary files stored on my web server and
Load the data into a ''MemoryStream'' object (namespace ''System.IO'').
2.) How can I use the browser (of a person using the
application) to open the files accordingly to their
extensions?



I don''t really understand what you want to do. You cannot open every file
type with the browser.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet


Hi,

Thank you both for your answer.

What I''d like to realize is a page with files on it represented as links. If
now somebody clicks on a link there should be the possibility to download
the file and/or open it (Like the dialog you get when you download sth. Let
it be a .doc file and your computer asks you whether you''d like to save it
or open it. The same happens when you download a .exe file. You''ll be asked
if you''d like to save or open the file.). The behaviour should be the same
as if somebody is downloading a file from a fileserver but the file should
be generated "of the fly" in the webserver''s memory (as it is coming out of
a SQL Server 2000) and then be posted back as if it was a download.

Thank you again for your help. I appreciate your effort.

Daniel


"Herfried K. Wagner [MVP]" <hi*******@m.activevb.de> schrieb im Newsbeitrag
news:#9**************@TK2MSFTNGP12.phx.gbl...

Hello,

"Daniel Walzenbach" <da**********************@freudenberg.de> schrieb:

Imagine the following situation: I have an asp.net
application which allows uploading files to a SQL Server
2000 database (Files are stored as type "images"). As a
next step I would like to implement some way to enable
downloading those files from the database which leads me
to the following two problems:
1.) How can I create a file "in memory" as I don''t want to
create temporary files stored on my web server and



Load the data into a ''MemoryStream'' object (namespace ''System.IO'').

2.) How can I use the browser (of a person using the
application) to open the files accordingly to their
extensions?



I don''t really understand what you want to do. You cannot open every file
type with the browser.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet



这篇关于如何从数据库创建文件并在浏览器中打开它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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