session_start(); // $file=glob($_SERVER['DOCUMETN_ROOT']."referenzen/referenz_".$_GET['dtnr'].".*"); // $file=glob($_SERVER['DOCUMETN_ROOT']."customer/".$_SESSSION['nummer']."/downl/".$_GET['dtnr']); // $filepath = $file[0]; $filepath = $_SERVER['DOCUMENT_ROOT']."/artikel/pdf/".$_GET['dtnr']; $_allowedApplications=array( "pdf"=>"application/pdf", "xls"=>"application/vnd.ms-excel", "doc"=>"application/msword", "txt"=>"text/plain", "csv"=>"text/csv", "xlsx"=>"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "docx"=>"application/vnd.openxmlformats-officedocument.wordprocessingml.document"); $pos=strrpos($_GET['dtnr'],"."); $lenght=strlen($_GET['dtnr']); $mime=substr($_GET['dtnr'], $pos+1,$lenght-$pos); $mimeType=$_allowedApplications[$mime]; if(file_exists($filepath)){ $headerstring="'Content-type: ".$mimeType."'"; header($headerstring); header('Content-Disposition: attachment; filename="'.basename($filepath).'"'); readfile($filepath); exit; //echo '
',var_dump($mimeType),''; }else{ echo "FEHLER! ERROR 404 -Datei nicht gefunden!