For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > May 2005 > file download suggestions









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author file download suggestions
Christian Giordano

2005-05-26, 8:55 am

I know that is a very old issue but testing an looking around didn't
help me so much. In php.net there is this code to make a file download:

<?php
// Date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");

// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);

// HTTP/1.0
header("Pragma: no-cache");

// We'll be outputting a PDF
header('Content-type: application/zip');

// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="test.zip"');

// The PDF source is in original.pdf
readfile('BlobDetection.zip');
?>

And it works fine in firefox, in IE instead when I go to the url it says:

"Internet Explorer cannot download download.php from..."


Any idea?


Thanks, chr
________________________________________
___________________________
{ Christian Giordano's site and blog @ http://cgws.nuthinking.com }
Steve

2005-05-27, 3:57 am

This might be a case of header overkill. I have a script creating and
outputting an RTF document, and the end of it looks like this:


header("Content-Type: application/rtf");
header("Content-Disposition: attachment;
filename=\"Action_Plan.rtf\"");
header("Content-Length: " . strlen($rtfdoc));
echo $rtfdoc;

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com