Hi!
I'd like to force a file download with this code :
<?php
$array = explode (".", $file);
$nb_element_1 = count ($array) -1;
if ($array[$nb_element_1] != "php") {
header("Content-disposition: attachment; filename=$file");
header("Content-Type: application/force-download");
header("Content-Transfer-Encoding: binary");
header("Content-Transfer-Encoding: text/plain\n");
header("Content-Length: ".filesize("../../tmp_file/".$file));
header("Pragma: no-cache");
header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
header("Expires: 0");
readfile("../../tmp_file/".$file);
}
else {
header("Location: quick_search.php");
}
?>
This code is registered in "download.php" located in my download folder.
In my html sheet, I call this code with :
echo '<a href="../../include/download.php?file='.$file.'">Download File</a>';
where "$file" is what I want to make upload...
When I click on the link "download", this make a download window appear but with a php file extention.
Is it the right code?
Could someone help me?
Thanks a lot!