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 |
Tell me how to find the position of the first occurrence of a substring in a string?
Why do we show php code in browser?
What is the difference between echo and print statement?
11 Answers Rushmore Consultancy,
List some array functions in php?
Is php object oriented?
How to add a cookie?
What is the correct and the most two common way to start and finish a php block of code?
Is empty in php?
What is filter_var?
Explain what are psrs? Choose 1 and briefly describe it?
What is difference between get and post?
Write a query to to delete duplicate rows?