$name = './img/ok.png'; $fp = fopen($name, 'rb'); // ΠΎΡΠΏΡΠ°Π²Π»ΡΠ΅ΠΌ Π½ΡΠΆΠ½ΡΠ΅ Π·Π°Π³ΠΎΠ»ΠΎΠ²ΠΊΠΈ header("Content-Type: image/png"); header("Content-Length: " . filesize($name)); // ΡΠΊΠΈΠ΄ΡΠ²Π°Π΅ΠΌ ΠΊΠ°ΡΡΠΈΠ½ΠΊΡ ΠΈ ΠΎΡΡΠ°Π½Π°Π²Π»ΠΈΠ²Π°Π΅ΠΌ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ ΡΠΊΡΠΈΠΏΡΠ° fpassthru($fp); exit;
Link to manual, example from the same http://php.net/manual/ru/function.fpassthru.php
More useful headlines: Content-Disposition , Content-Length
As a rule, with this approach, a temporary link to the file is created, stored in the database. The link consists of a hash and file path. Hash is shown to the user, the path is not shown. As soon as the user has downloaded the file - mark the link used or simply delete it from the database.