473,378 Members | 1,631 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,378 software developers and data experts.

forced file download

Wrote a script (tried to;) which should force to download a pdf-file, but it
doesn't work on every browser.
What should be changed ?

SCRIPT:
---------

<%
Dim Stream
Dim Contents
Dim strFileName
Dim strFilePath

strFileName = "download.pdf"

strFilePath = Server.MapPath(strFileName)

Response.ContentType = "application/octet-stream"
Response.AddHeader "content-disposition", "attachment; filename=" &
strFileName

Set Stream = server.CreateObject("ADODB.Stream")
Stream.Open
Stream.LoadFromFile strFilePath
Contents = Stream.ReadText
Response.BinaryWrite Contents
Stream.Close
Set Stream = Nothing
%>

TESTED ON:
--------------
PC:
IE6+: ok
OPERA7+: ok

NS7+: gives a saveas-popup but adds ".asp" to the file "download.pdf" =>
download.pdf.asp
MOZ1.2+: same as NS7
OPERA6+: don't work, displays a lot off sh*beep*t

MAC
SAFARI: ok
IE5.2: gives popup but pdf can't be opened due to decoding-error?


Jul 19 '05 #1
1 3628

"Don Verhagen" <ne**@southeast-florida.com> wrote in message
news:bd*************@ID-181477.news.dfncis.de...

"dany" <da***************@yucom.be> wrote in message
news:vm***************@afrodite.telenet-ops.be...
Wrote a script (tried to;) which should force to download a pdf-file,
but it
doesn't work on every browser.
What should be changed ?
Doesn't work would mean?

Every browser? What browsers? What Versions? What OS's?


Did you look at the bottom of the message under the script???

Don

SCRIPT:
---------

<%
Dim Stream
Dim Contents
Dim strFileName
Dim strFilePath

strFileName = "download.pdf"

strFilePath = Server.MapPath(strFileName)

Response.ContentType = "application/octet-stream"
Response.AddHeader "content-disposition", "attachment; filename=" &
strFileName

Set Stream = server.CreateObject("ADODB.Stream")
Stream.Open
Stream.LoadFromFile strFilePath
Contents = Stream.ReadText
Response.BinaryWrite Contents
Stream.Close
Set Stream = Nothing
%>

TESTED ON:
--------------
PC:
IE6+: ok
OPERA7+: ok

NS7+: gives a saveas-popup but adds ".asp" to the file "download.pdf" =>
download.pdf.asp
MOZ1.2+: same as NS7
OPERA6+: don't work, displays a lot off sh*beep*t

MAC
SAFARI: ok
IE5.2: gives popup but pdf can't be opened due to decoding-error?


Jul 19 '05 #2

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

Similar topics

1
by: dany | last post by:
I want a forced PDF-download but all that header-stuff is new for me.... I wrote a little asp-script: <% Filename = "download.pdf" response.addheader "content-disposition","attachment;...
2
by: Gary D. Rezek | last post by:
Hi All, First of all I'm mostly an MS Access guy (and novice learning MSSQL guy) and put on this project because of personnel changes, etc and because of db experience. I've only been doing this...
1
by: d. | last post by:
I coded a simple asp-script to force a file-download. (ex. dummy.doc) In IE6, NS4.7 and Opera 7 everything works fine and the file can be easily downloaded... But NS7 renames the filename in...
22
by: MyndPhlyp | last post by:
I am pushing a file download to the client. The ASP used to generate and push the file is triggered by an <a target="_blank" href="something">. The VBScript uses Response.Clear...
13
by: Mickey | last post by:
Hi all, Currently I use a timestamp to log users out after 15 minutes of inactivity. However I also need to log a user out if they have just left the page. I need to do this because I store...
2
by: comp.lang.php | last post by:
if ($forceDownload) { // HANDLE FORCED DOWNLOAD $dlGen =& new DownloadGenerator($fullFilePath); $negativeIndex = $dlGen->generateForceDownloadHeaders(); $willDeleteTemp =...
14
by: Simon Rigby | last post by:
Hi folks, I appreciate that this topic of forced downloads has been discussed in various threads but my situtation is a little different to those that I have come across and am experiencing a...
12
by: comp.lang.php | last post by:
index.php: // STUFF // STEP 1: imagecreatetruecolor ONLY IF GD 2.0+ SUPPORTED AND FOUND if ($this->isSuccessful && !$hasMogrified && $image && !$newImage &&...
4
by: Irfan12 | last post by:
I am using the following PHP code to force the internet browser to download a media file(e.g, .mp3, .wma), But in this code, there is no resume support in downloading these files. i dont know PHP,...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.