hi
I basically just need to have the user have the downlaod box and get the user to save the file.
I haven't tried an absolute link, thanks. I think just need to get the header data correct so that it reads it as a download
4:34 pm on May 18, 2005 (utc 0)
force download script should always be the first one to spit anything to the browser on a page.
other wise it would not work.
I am using a download.php for this purpose, I just pass the url and its starts downloading.
I have also found the following piece of code, which i can cut down, which i will also try tonight.
If I used an absolute link would i need to set the header information like in the code below?
many thanks for your help
<?php
$filename = // your parameter
$filename = realpath($filename); //server specific
$file_extension = strtolower(substr(strrchr($filename,"."),1));
if (! file_exists( $filename ) )
{
die("NO file HERE";
};
switch( $file_extension )
{
case "jpe": case "jpeg":
case "jpg": $ctype="image/jpg"; break;
default: $ctype="application/force-download";
}
header("Pragma: public"); // required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false); // required for certain browsers
header("Content-Type: $ctype");
header("Content-Disposition: attachment; filename=".basename($filename).";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".@filesize($filename));
@readfile("$filename") or die("file not found.");
exit();
😉