Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

force download with content-type?

Status
Not open for further replies.

rubychyld

Programmer
Mar 22, 2001
76
0
0
US
How to do this... I would like to change the content-type, header info, or mime type so the browser takes a .pdf file and prompts the dialog box "open from current location or save to disk". Normally winzip is useful for downloads, but not this time.

Please help send me in the right direction.
Thanks, Liz Catch the vigorous horse of your mind!
 
hey there,

I have also been trying to acheive this so i have had a look at the info on MSDN and I found it difficult to get it working.

It looks like this method is only to download text files and not binary format stuff like .PDF (see quote below), I did follow the examples to the letter and got the result it says i should but no download.

"The startDownload method returns only the content of text documents. If a different document format is downloaded, the format is returned, but the file content is not." - MSDN

Any more help with this would be great .


Cheers

JEz
 
Has anyone used the following?::
Response.AddHeader "Content-Disposition", "attachment; filename=A.PDF"

I put this in the top of an asp file and it should prompt the user to download the "A.pdf" file as soon as they enter the page....

However, it doesn't seem to work all the time for me.

JEz, Let me know if you get it to work.

Anyone doing this???

Liz

Catch the vigorous horse of your mind!
 
Liz,

I have just tried this ASP response and the first time i browsed that page it tried to open the named PDF document, but then each time after that, nothing. I'm not that hot on ASP but it did the same for me as for you.

However, when it did 'work' it opened the PDF document from it's current location, something that can be done with the following javascript:-

in the head section of the page,

function opendoc () {
window.open('a.pdf', '_blank')
}

then,

<body onload=&quot;opendoc();&quot;>

What i am trying to do with this is force the docuemnt to be downloaded rather than openned from where it is.
To explain a bit more, if you click on a link to PDF document and you have acrobat reader, it will try and open it (likewise with any office document if you have MSoffice installed).
If these documents are quite big, you end up with a blank window that stays blank until the entire docuemnt is downloaded (a long time for over 1MB on a dial-up connection) and this can timeout or fail easily, but if links are set to a particular content-type (??) then clicking would automaticaly initiate a download.
I just cant find out how this is done.

The info given by SMSFORCE above is exactly what i'm looking for, but as ever the information on the microsift site isn't clear about exactly what you need to do to acheive this, it just strongly suggests it can be done.

Thanks anyway,


Jez

:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top