Great news.
I have managed to get it working by putting the include file at the beginning of the script & it now opens PDF files no problem.
However, other files such as Excel & jpeg files it doesn't open.
If I try to open a jpeg file I just get a box with a red cross.
If I try to open an excel (xls) file it opens in excel but it displays all the information in symbols, etc.
This is my modified script: -
<?php
if (isset($POST['pricelist']))
{
$getfile = $POST['pricelist'];
// define error handling
$nogo = 'Sorry, download unavailable.';
if (!$getfile)
{
// go no further if filename not set
echo $nogo;
}
else
{
// define the pathname to the file
$filepath = 'c:/htdocs/panasonic_system_pricing/'.$getfile;
// check that it exists and is readable
if (file_exists($filepath) && is_readable($filepath))
{
// get the file's size and send the appropriate headers
$size = filesize($filepath);
header('Content-Type: application/pdf/jpg/jpeg/xls/doc');
header('Content-Length: '.$size);
header('Content-Disposition: attachment; filename='.$getfile);
header('Content-Transfer-Encoding: binary');
// open the file in binary read-only mode
// suppress error messages if the file can't be opened
$file = @ fopen($filepath, 'rb');
if ($file)
{
// stream the file and exit the script when complete
fpassthru($file);
exit;
}
else
{
echo $nogo;
}
}
else
{
echo $nogo;
}
}
}
?>