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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Force download problem when save

Status
Not open for further replies.

DeSn

Programmer
Joined
Nov 20, 2001
Messages
111
Location
BE
I have a php-page with some links to download files. One of the links is this one:
<a href=&quot;downldpg.php?filename=test.HDR_ENVI&quot;>test</a>

This is the code from my downldpg.php page.

<?php
// fix for IE catching or PHP bug issue
header(&quot;Pragma: public&quot;);
header(&quot;Expires: 0&quot;); // set expiration time
header(&quot;Cache-Control: must-revalidate, post-check=0, pre-check=0&quot;);
// browser must download file from server instead of cache

// force download dialog
header(&quot;Content-Type: application/force-download&quot;);
header(&quot;Content-Type: application/octet-stream&quot;);
header(&quot;Content-Type: application/download&quot;);

// downloading a file
$filename = $_GET['filename'];

// use the Content-Disposition header to supply a recommended filename and
// force the browser to display the save dialog.
header(&quot;Content-Disposition: attachment; filename=&quot;.basename($filename).&quot;;&quot;);

header(&quot;Content-Transfer-Encoding: binary&quot;);
header(&quot;Content-Length: &quot;.filesize($filename));

readfile(&quot;$filename&quot;);
exit();
?>

I get the save dialog box. When I choose cancel or open everything works fine. When I choose save, my website blocks, i can't go to an other page anymore??? I work with IE6, can anyone help me???
 
thats because the page is supposed to have gone to the download page. u are no longer in the original page. try this:
<a href=&quot;downldpg.php?filename=test.HDR_ENVI&quot; target=&quot;new&quot;>test</a>


Known is handfull, Unknown is worldfull
 
OK, this works (thanks), but then I have a page that I have to close eache time :(
 
well when i was placed with that problem i changed all the links into js links. let me llok into what i did...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top