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 |
In what are the ways you can encrypt the password ?
Is there any way to call a JAVASCRIPT function in PHP in AJAX
Write a program using while loop in php?
can we swap two different string using php for example:-- before swapping:-- 1 string :-hello friend, 2 string :-my dear, after swapping that strings will be: 1.hello dear, 2.my friend.
How do you display the output directly to the browser?
What is the use of offset in mysql?
How can you count number of parameters given in a URL by POST method?
What are string functions?
How will you calculate days between two dates in PHP?
Why does php start with variables?
Tell me in php, objects are they passed by value or by reference?
how can refresh current page automatically, without press any button and anchor tag.