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 is the difference between mysql_fetch_array() and mysql_fetch_assoc()?
what is array_search() in php?
What is difference between include,require,include_once and require_once()?
What are regular expressions in programming?
Is php difficult to learn?
What is the importance of "action" attribute in a html form?
Which function parses an English textual date or time into Unix timestamp in PHP.
How to remove duplicate values from a PHP Array?
Are php sessions cookies?
Tell me what is the default session time in php?
What is PHP? Who is the father or inventor of PHP?
Explain the difference b/w static and dynamic websites?