Tutorialsplane

PHP File Download


PHP File Download:– When we click on a link pointing to text files,executable files(.exe extention file) etc ; these files has been saved in computer’s hard drive after clicking that href link but some file format like pdfs or .jpg files do not allow browser to download them. So in this scenerio we create a php script which allows a file to download.

In this tutorial I will show you how to create a link to a file which prompts the user for a download.

Note:–You should keep all files(jpg,png,pdf etc) for download inside htdocs.

Example // how to create a download link for .jpg type image






<?php echo '<div class="img-box"?>';
echo '<amp-img src="Tulips.jpg" width="200" height="100" alt="img error" sizes="(min-width: 200px) 200px, 100vw" class="amp-wp-enforced-sizes"></amp-img>';
echo "<p>Download image</p>";
?>

PHP Tutorial