User Name Password Register
DaniWeb IT Discussion Community
All
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 329,104 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,532 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: 15784 | Replies: 25
Closed Thread
Join Date: Aug 2005
Posts: 100
Reputation: martinkorner is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
martinkorner's Avatar
martinkorner martinkorner is offline Offline
Junior Poster

Solution Re: Save Target as...

  #21  
Feb 15th, 2006
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
 
Join Date: Oct 2004
Location: San Francisco, CA
Posts: 337
Reputation: paradox814 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
paradox814's Avatar
paradox814 paradox814 is offline Offline
Posting Whiz

Re: Save Target as...

  #22  
Feb 21st, 2006
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
 
Join Date: Aug 2005
Posts: 100
Reputation: martinkorner is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
martinkorner's Avatar
martinkorner martinkorner is offline Offline
Junior Poster

Question Re: Save Target as...

  #23  
Feb 21st, 2006
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: paradox814 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
paradox814's Avatar
paradox814 paradox814 is offline Offline
Posting Whiz

Solution Re: Save Target as...

  #24  
Feb 22nd, 2006
$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]
 
Join Date: Aug 2005
Posts: 100
Reputation: martinkorner is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
martinkorner's Avatar
martinkorner martinkorner is offline Offline
Junior Poster

Question Re: Save Target as...

  #25  
Feb 22nd, 2006
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
 
Join Date: Dec 2004
Posts: 1,589
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 33
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Save Target as...

  #26  
Feb 22nd, 2006
I'd like to close this thread - it's drifting too far. Please start a new thread in the PHP forum.
 
Closed Thread

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Marketplace (Sponsored Links)
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 7:20 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC