'png', 'image/svg+xml'=>'svg'); if(!isset($allowed[$_REQUEST['type']])) exit('Invalid export type'); if(!preg_match("/(".implode("|",$allowed).")$/i",$_REQUEST['filename'])) $_REQUEST['filename'].='.'.$allowed[$_REQUEST['type']]; header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Disposition: attachment; filename=".$_REQUEST['filename']); header("Content-Type: ".$_REQUEST['type']); header("Content-Transfer-Encoding: binary"); if($allowed[$_REQUEST['type']]!='svg') echo base64_decode(substr($_REQUEST['image'],strpos($_REQUEST['image'],',')+1)); else echo $_REQUEST['image']; } else exit('Invalid request'); ?>