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 |
Is php a framework?
Explain Booleans in PHP?
How can we know the total number of elements of Array?
How to enable parsing?
How to strip whitespace (or other characters) from the beginning and end of a string?
What is isset in php?
What is putenv?
What is string function sql?
what are the current or latest versions of LAMP ? Linux, Apache, MySql, PHP
Explain different types of errors in PHP (i.e. arguments in errorreporting function)?
8 Answers Base2 Infotech, DCI, Microsoft, Tata Elxsi,
What are form input html tags?
Explain how to execute a php script using command line.