二进制文件在asp.net的浏览器中打开 [英] binary files open in browser in asp.net

查看:126
本文介绍了二进制文件在asp.net的浏览器中打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hiii

如何使用数据库和pdf文件在浏览器中打开pdf文件另存为varbinary(MAX)。



请给我解决方案。

hiii
how to pdf file open in browser using database and pdf file save as varbinary(MAX).

Please give me a solution.

推荐答案

使用可以保存临时文件的文件夹。将文件(使用唯一的文件名!)保存到此文件夹,并提供指向该用户的链接。将文件名保留在Session对象中。



当会话结束时(我相信这是global.asax文件中的一个事件),你可以使用该值并删除来自磁盘的文件。



希望这会有所帮助。
Use a folder that can hold temporary files. Save the file (with a unique filename!) to this folder and provide the link to the user. Keep the filename in the Session object.

When the session ends (I believe this is an event in the global.asax file) you can use that value and delete the file from disk again.

Hope this helps.


Hi
试试这样,从sql获取二进制文件并使用文件流你保存在临时文件夹中并显示pdf格式的临时文件夹。



Hi Try like this ,get binary files form sql and using file stream u save in temp folder and show pdf form that temp folder.

 Dim buffer As Byte()
 buffer = fadt(0)("PDF")'--This pdf in the form of binary
Dim fs As FileStream = File.Create(docflxpath)'---Save pdf path
fs.Write(buffer, 0, buffer.Length)
fs.Close()
fs.Dispose()
buffer = Nothing





以上我会选择文件名,二进制形式和二进制形式填充数据表,这里我使用fadt并使用此数据表我将该二进制文件传递给缓冲区,docflxpath正在保存pdf文件路径,在此你给出类似C:\\\\\\\\\\\\\\然后它将文件名保存为.pdf在C:\ test



然后显示pdf格式为C:\ test文件夹。





注意:

for docflxpath你需要给出名字并最后添加.pdf



问候

Aravind



in above i will select file name ,binary form and that binary form fill in datatable,here i use fadt and using this datatable i will pass that binary to buffer and docflxpath is saving pdf file path ,in this u give like "C:\test\documentname.pdf" then it save documentname with .pdf in C:\test

then show pdf form C:\test folder .


Note :
for docflxpath u need to give name and add .pdf at last

Regards
Aravind


这篇关于二进制文件在asp.net的浏览器中打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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