As in html or php to make a link to download images from the site. That is, that when clicking on a link, a browser window would open with a suggestion to save the file. We need the easiest and most reliable way that will work in all new browsers.

    1 answer 1

    A link of this type:

    <a href="download.php?file=arrow.png">Скачать картинку</a> 

    And there:

     <?php $filename = ''; if (isset($_GET['file'])) $filename = $_GET['file']; if (file_exists($filename)) { header("Content-type: application/x-download"); header("Content-Disposition: attachment; filename=$filename"); readfile($filename); } else { header("HTTP/1.1 404 Not Found"); echo '404 Not Found'; } ?> 
    • and in what places the file name to register? - sportcar
    • 2
      In the link: <a href="download.php?file=WOTH_UTUT_IMATE_FILE"> Download picture </a> - ferrari