•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 328,931 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,088 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 15780 | Replies: 25
![]() |
I mainly use Firefox instead of IE now, so I don't have the problem anymore :lol:
Firefox is good, but some parts of websites that work on IE don't work on it - I think that's it's only negative point.
Martin
Firefox is good, but some parts of websites that work on IE don't work on it - I think that's it's only negative point.
Martin
•
•
Join Date: Oct 2004
Location: San Francisco, CA
Posts: 337
Reputation:
Rep Power: 4
Solved Threads: 0
this can be done in php by using the header function, without the need of javascript and it works in safari, internet explorer, mozilla (firefox), etc...
since you are using an html forum I'm assuming that this wasn't what you were looking for though
since you are using an html forum I'm assuming that this wasn't what you were looking for though
•
•
•
•
Originally Posted by paradox814
this can be done in php by using the header function, without the need of javascript and it works in safari, internet explorer, mozilla (firefox), etc...
since you are using an html forum I'm assuming that this wasn't what you were looking for though
No, it's fine.
How would I make a download dialogue box appear when a user opens a certain page using PHP?
Thanks
Martin
•
•
Join Date: Oct 2004
Location: San Francisco, CA
Posts: 337
Reputation:
Rep Power: 4
Solved Threads: 0
$file is the actual file (with the path included)
$new_filename is the filename that you want to send to the user. So when they download this will be the name used by the browser
the first 3 headers force the browser to download the file each and every single time, eg it's not pulling it from the memory/dish cache
the content type is just sent as some binary data type
the content-disposition tell the browser to force a download, do not open in the browser, even if you have a plugin to open it.
i use this script for images, word documents, pdfs and it works just fine.
[php]if (is_file($file))
{
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Pragma: no-cache");
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=".$new_filename);
readfile($file);
exit();
}[/php]
$new_filename is the filename that you want to send to the user. So when they download this will be the name used by the browser
the first 3 headers force the browser to download the file each and every single time, eg it's not pulling it from the memory/dish cache
the content type is just sent as some binary data type
the content-disposition tell the browser to force a download, do not open in the browser, even if you have a plugin to open it.
i use this script for images, word documents, pdfs and it works just fine.
[php]if (is_file($file))
{
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Pragma: no-cache");
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=".$new_filename);
readfile($file);
exit();
}[/php]
Sorry, I'm quite new to PHP and I'm not sure how I'd go about putting this script onto my site.
Could you give me a working example of this?
Thanks
Martin
Could you give me a working example of this?
Thanks
Martin
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
DaniWeb Marketplace (Sponsored Links)
- "Save Target As.." isn't working in IE6 (Web Browsers)
- Save target as... (Windows NT / 2000 / XP / 2003)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: form event problem
- Next Thread: Problem in hovering


Linear Mode