<?php $file = $_GET['f']; $file = explode(".", $file); if(file_exists("uploads/{$file[0]}.{$file[1]}")) { header("Content-type: application/{$file[1]}"); header("Content-Disposition: attachment; filename={$file[0]}.{$file[1]}"); readfile("{$file[0]}.{$file[1]}"); } else { echo "file doesn't exists"; } ?>