473,407 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Retrieve pdf files from SQL Server

Hi

Doesn anyyone know the proper lines of ASP code to sucessfully retrieve a pdf file from SQL server. Everytime I run my code I get gibberish all over the screen. I would like it to prompt me to save the file to disk

Thanks

-Jeff
Jul 19 '05 #1
3 2871
I don't know if this is what your looking for but see code below

I use this in a file called getfile.asp. On a web page listing documents (of
any type really) you would click a link to the getfile.asp sending the file
name and an action in the querystring.

For this example sending Now or Later as the action will either do the Save
As prompt or will open the document in the browser window.

There is also a call to a stored proc that will track the amount of times
the file was accessed.

Hope this helps.
=================
Dim strFile, strFileAction

strFile = Request.QueryString("file")
strFileAction = Request.QueryString("action")

If strFile <> "" Then
Call ExecQuery(connString, "EXEC procPublic_LibFileClick '" & strFile &
"'")
If strFileAction = "later" Then
'On Error Resume Next

Dim strFilePath, strFileSize, strFileExt, strFileType
Dim objSendFile

strFilePath = Server.MapPath(strFile)
'Response.Write strFilePath

'Set objSendFile = Server.CreateObject("Persits.Upload")
'objSendFile.SendBinary strFilePath, True, "application/octet-stream",
True

Set objSendFile = Server.CreateObject("ADODB.Stream")
objSendFile.Open
objSendFile.LoadFromFile strFilePath

Response.ContentType = "xxx/xxx"
Response.AddHeader "content-disposition", "attachment; filename=" &
strFile
Response.BinaryWrite objSendFile.ReadText
Set objSendFile = Nothing

If Err.Number <> 0 Then
'Call TrapError(Err.Number, Err.Description, Err.Source)
End If
ElseIf strFileAction = "now" Then
With Response
.Write "<html><head></head><body onload=""window.document.location='" &
strFile & "'""></body></html>"
End With
End If
End If
"Jeff Fenn" <fe**@bravuranetworks.com> wrote in message
news:74**********************************@microsof t.com...
Hi,

Doesn anyyone know the proper lines of ASP code to sucessfully retrieve a pdf file from SQL server. Everytime I run my code I get gibberish all over
the screen. I would like it to prompt me to save the file to disk.
Thanks.

-Jeff

Jul 19 '05 #2
Thanks, that worked.
Jul 19 '05 #3
Glad to hear... good luck.

"Jeff" <an*******@discussions.microsoft.com> wrote in message
news:66**********************************@microsof t.com...
Thanks, that worked.

Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: jandt | last post by:
I know that you can retrieve data from a form using Request.Form("name"), but how do you retrieve a file?
16
by: Daniel Tonks | last post by:
First, please excuse the fact that I'm a complete MySQL newbie. My site used forum software that I wrote myself (in Perl) which, up until now, has used flat files. This worked fine, however...
7
by: Leszek | last post by:
Hello, I need to set dynamically height and width attributes of an image control on a WebForm. I know how to read the whole image from the hard-drive and use its height and width properties. I...
2
by: John | last post by:
Hi all, I haven't a clue where to begin here (or more to the point - if it's even possible). I need to read the names of all the files inside a folder off my web site. The catch here is that...
3
by: Richard Thornley | last post by:
Hello, I was just been given a project and I have some questions on how to accomplish the first part of the task. If a user sends an email to a specific email address I need to detect...
3
by: bazubwabo | last post by:
hi everybody , could u please help me to find out the error on my asp codes,i can't retrieve the inserted values. Here is below the code: <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <!DOCTYPE...
12
by: nirajjha | last post by:
hi, i am able to connect to server through socket, (using only client side code ) but not able to retrieve files , i dont able to find files but its there in the server. i am getting...
2
by: =?Utf-8?B?QnVzYnk=?= | last post by:
Hi I need to retrieve a list of all WebServices running on a specific machine. Much like DevStudio produces a list of WebServices on the local machine. The machine is XP Pro and as far as I...
2
by: =?Utf-8?B?SmVmZlAtPg==?= | last post by:
I want to retrieve an image file (TIF) convert it to a bmp file and enable sizing. I know how to do the converting & sizing part, and store any atributes to file location in the webconfig, what...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.