I created a download function in php in which the file contains special characters in it.
but while downloading the file, the file name breaks from some special characters.
mainly while obtaining a space in file name.
my download function is this.
function download(){
$filename = "google _(){}[]valentine~!@#$%^&*()_+`1=-.flv";
$filepath = "uploads/" . $filename;
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
//setting content type of page
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=" . $filename);
header("Content-Description: File Transfer");
//Read File it will start downloading
readfile($filepath);
}
You should try to escape spaces with a “\ “.
Like this: