Case: user select a file from a list and push download.
Then I tries to force a download dialog box to open for the user to get
the opportunity to save or open.
What I have tried is ( the file is an pdf-file)
the path is the full path.
header ("Content-Type: application/pdf");
header("Content-Disposition: atachment; filename=".$path);
readfile($path);
What happens. the file get printet out to the screen in binary or
something.
Someone, what is wrong?
Sindre
--
Sender med M2, Operas revolusjonerende e-postprogram: http://www.opera.com/
Instead of supplying a full path just do filename=document.pdf and a
download window will appear proposing the file to be saved somewhere as
document.pdf
Ok, I have tried only the filename. Nothing at all happens.
Her is more code
$fileName= $fileName .".pdf";
echo ("filename =$fileName");
if(is_file($fileName))-> true
{
echo("test");
$filesize = filesize($fileName);
echo ("filesize = $fileSize"); //filesize = nothing
}
echo ("filesize = $fileSize");
header ("Content-Type: application/pdf");
header("Content-Disposition: atachment; filename=".$fileName);
readfile($fileName);
anyone. ?
(I have tried it in both opera and explorer )
Sindre
One mistake you make is to output things to the browser before setting
headers... this is not ok and might be the reason noting happens.... so
remove all echo's in the lines preceeding the headers...
Marcel