function _serveFile($key) { ini_set("memory_limit","128M"); $file = $this->_data[$key]; if(isset($file) && !empty($file)) { $ext = end(explode(".", $file)); $allowed = array("doc","rtf","txt","pdf","xls","jpg","png","tiff","jpeg"); //if(in_array($ext,$allowed)) { if(1) { switch($ext) { case "txt": $type = "text/plain"; break; case "rtf": $type = "application/rtf"; break; case "doc": $type = "application/msword"; break; case "docx": $type = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; case "xls": $type = "application/vnd.ms-excel"; break; case "pdf": $type = "appliction/pdf"; break; case "png": $type = "image/png"; break; case "gif": $type = "image/gif"; break; case "jpg": case "jpeg": $type = "image/jpeg"; break; case "tiff": $type = "image/tiff"; break; default: $type = "application/octet-stream"; break; } $name = $this->_data['first_name']."_".$this->_data['last_name']."_".$key.".".$ext; $tmp = $this->_createDecryptedTmpFile(UPLOAD_DIR.DS."files".DS.$file); header("Pragma:public"); header("Expires:0"); header("Cache-Control:must-revalidate,post-check=0,pre-check=0"); header("Cache-Control:private",false); header("Content-Type:application/force-download"); header("Content-Type:application/download"); header("Content-Description:File Transfer"); header("Content-type:".$type); header("Content-disposition: attachment; filename=".$name); header("Content-Length:".filesize($tmp)); echo file_get_contents($tmp); } else { echo "The file type $ext is not allowed"; } } }