Hi,
I have taken your advice & changed the script to the following: -
<?php
if (isset($_POST['pricelist']))
{
$getfile = ($_POST['pricelist']);
// define the pathname to the file
$filepath = 'C:/htdocs/panasonic_system_pricing/'.$getfile;
$ext = substr($filepath, strrpos($filepath, '.')+1);
switch ($ext)
{
case 'pdf':
$type = 'application/pdf';
break;
case 'jpg':
case 'jpeg':
$type = 'image/jpeg';
break;
case 'xls':
$type = 'application/vnd.ms-excel';
break;
}
// 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: '.$type);
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;
}
}
}
?>
The problem is that if for example I try to open an Excel file I get the following: -
Warning: Cannot modify header information - headers already sent by (output started at C:\htdocs\Panasonic_system_pricing.php:3) in C:\htdocs\includes\Panasonic_system_pricelist_download.inc.php on line 34
Warning: Cannot modify header information - headers already sent by (output started at C:\htdocs\Panasonic_system_pricing.php:3) in C:\htdocs\includes\Panasonic_system_pricelist_download.inc.php on line 35
Warning: Cannot modify header information - headers already sent by (output started at C:\htdocs\Panasonic_system_pricing.php:3) in C:\htdocs\includes\Panasonic_system_pricelist_download.inc.php on line 36
Warning: Cannot modify header information - headers already sent by (output started at C:\htdocs\Panasonic_system_pricing.php:3) in C:\htdocs\includes\Panasonic_system_pricelist_download.inc.php on line 37
ÐÏࡱá>þÿ æþÿÿÿþÿÿÿäåÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ©ÍÉÀá°Áâ\pLee Wolstencroft B°aÀ=º ThisWorkbookœ¯¼=xx¶:Ò8X@"·Ú1ÈÿoArial1ÈÿoArial1ÈÿoArial1ÈÿoArial1È$oArial1È oArial1È oArial1 ÿoArial1 oArial1ÈoArial1 oArial1 ¼oArial1 oArial1 oArial1È oArial1 ÿ¼oArial1 ¼oArial1 ¼oArial"£"#,##0;\-"£"#,##0"£"#,##0;[Red]\-"£"#,##0"£"#,##0.00;\-"£"#,##0.00#"£"#,##0.00;[Red]\-"£"#,##0.005*0_-"£"* #,##0_-;\-"£"* #,##0_-;_-"£"* "-"_-;_-@_-,)'_-* #,##0_-;\-* #,##0_-;_-* "-"_-;_-@_-=,8_-"£"* #,##0.00_-;\-"£"* #,##0.00_-;_-"£"* "-"??_-;_-@_-4+/_-* #,##0.00_-;\-* #,##0.00_-;_-* "-"??_-;_-@_-¤ "£"#,##0.00¥mmmm\ d\,\ yyyy ¦0.0%§"Yes";"Yes";"No"¨"True";"True";"False"©"On";"On";"Off"ª[$-809]dd\ mmmm
Any idea's?
[ Mod Edit - bpat1434 ] Please use [noparse]
and
[/noparse] tags around your php code and general code respectively.