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 a variable is declared in php?
How can we submit from without a submit button?
Is php faster than javascript?
Is php easy language to learn?
What are the different errors in php?
What is query string php?
What is session_start () in php?
Why do we use cookie?
how can i find number of rows in a table using MS Access and php? i used odbc_num_rows($query); but it returned -1.
Explain do you use composer? If yes, what benefits have you found in it?
How to create a table using php?
Explain me what is the goto statement useful for?