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 |
How do you execute a php script from the command line?
How to uploaded files to a table?
Tell me what the difference between the 'bitwise and' operator and the 'logical and' operator?
what is php stands for?
23 Answers Infosys, Satyam, Torque Infotech,
How to split a string into array using php?
What is php key?
What is php and how do you use it?
how to include external php file in to html page?
how to run PHP in command line?
8 Answers InfoShore, Ramp Green, Xtreeme,
Explain the different types of errors in php.
What is csrf cookie?
Does php have multiple inheritance?