php force-download file

SERVER SIDE download.php

$file_path = $_GET["file"];
header('Content-disposition: attachment; filename='.$file_name);
header('Content-type: application/force-download;');
readfile($file_path);

CLIENT SIDE

<a href="download.php?file=xxx.jpg">click_to_download</a>

Related posts:

This entry was posted in php, เกร็ดความรู้. Bookmark the permalink.