Solved

set default filename when saving binary-written-to-browser pdf

Posted on 2004-10-06
2
1,138 Views
Last Modified: 2008-01-09
i am displaying PDF files in a web browser using asp

i am trying to set the default filename (that appears in the file name box) when the "save a copy of the file" button is clicked, but it seems that i can't

following is my code:

Response.Buffer = True
Response.Clear
Response.ContentType = "application/pdf"
Response.AddHeader "Content-Disposition", "inline; filename=x.pdf"
Response.BinaryWrite sBinaryFile
Response.Flush
Response.End

any ideas?

thanks,

f
0
Comment
Question by:papaflo
  • 2
2 Comments
 
LVL 10

Accepted Solution

by:
dij8 earned 50 total points
ID: 12242941
You have no control over these kind of boxes that appear on the clients browser.  This is a security issue.  It is also that the save as dialog box is not actually part of the browser but part of the native operating system.  The box will always come up with the name of the file being saved, in this case "x.pdf".

A way around this is to use the FileSystemObject and copy the PDF document to a folder naming it whatever you want and then rendering the page using the copied file.  This will still open the save as dialog with the given file name except you have controlled the name on the server.
0
 
LVL 10

Expert Comment

by:dij8
ID: 12302723
Glad I could help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

1 Experts available now in Live!

Get 1:1 Help Now