How to download the files using PHP
Answer / vishwapati_mishra
<?
$dir="/path/to/file/";
if (isset($_REQUEST["file"])) {
$file=$dir.$_REQUEST["file"];
header("Content-type: application/force-download");
header("Content-Transfer-Encoding: Binary");
header("Content-length: ".filesize($file));
header("Content-disposition: attachment;
filename=\"".basename($file)."\"");
readfile("$file");
} else {
echo "No file selected";
}
?>
| Is This Answer Correct ? | 7 Yes | 2 No |
What are getters and setters and why are they important?
What does $_server means?
How cookies are transported from browsers to servers?
Why post method is used in php?
Does it possible to compile php with mysql without having mysql sources?
How can we check the value of a given variable is a number?
Which is the best method to fetch the data from mysql? 1.mysql_fetch_array() 2.mysql_fetch_object() 3.mysql_fetch_row() 4.mysql_fetch_assoc()
What is difference between action hook and filter hook?
Is it possible to remove the html tags from data?
What is the default session out time?
Tell me what is the difference between ereg_replace() and eregi_replace()?
What is a composer?