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 can we extract string ?allinterview.com ? from a string ?http://info@allinterview.com? using regular expression of PHP?
What are the functions of string?
What are classes in php?
What is helper library?
Describe PHP error and logging information?
How long does a php session last for?
What does the initials of php stand for?
How to upload any files extension in our database Ex.(.doc,.txt,mp4,mp3 etc.)in php
What is PHP's configuration file called?
What is the difference between php 5 and php 7?
What is meant by an associative array?
Which is the dependent variable?