Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


How to download the files using PHP



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

Post New Answer

More PHP Interview Questions

What are the encryption techniques in php?

0 Answers  


Is age interval or ordinal data?

0 Answers  


how can i get USA time using php...

1 Answers  


Explain what is the main difference between require() and require_once()?

0 Answers  


What is ci in php?

0 Answers  






How can we enable error reporting in php?

0 Answers  


Does php pass arrays by reference?

0 Answers  


What is api used for?

0 Answers  


What's the best method for sanitizing user input with php?

0 Answers  


Difference between array_combine and array_merge?

0 Answers  


How to call php function in jquery?

0 Answers  


Can I use node js with php?

0 Answers  






Categories