Php: How to protect images for downloading [duplicate]

you can do this by using force download in php.

$file_url="base path to file / file name";
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary"); 
header("Content-disposition: attachment; filename=\"" . basename($file_url) . "\""); 

this code will download the file and block files folder using htaccess

<IfModule authz_core_module>
   Require all denied

<IfModule !authz_core_module>
   Deny from all

Browse More Popular Posts

Leave a Comment