Reputation: 1
Hello everyone I am developing a PHP MVC framework and I reached a point where I need to offer the user some files and I don't know how ro create the download link I know it sounds childish but I tried to make hyperlink to the address of the document but it seems not to work....Some documentation would be ideal
Upvotes: 0
Views: 380
Reputation: 3634
$fullpath = $_SERVER['DOCUMENT_ROOT']."/foldername/document.pdf"; //Full path of document
$filename = "document.pdf"; //Document file nmae
$mm_type="application/octet-stream";
header("Cache-Control: public, must-revalidate");
header("Pragma: hack");
header("Content-Type: " . $mm_type);
header("Content-Length: " .(string)(filesize($fullpath)) );
header('Content-Disposition: attachment; filename="'.$filename.'"');
header("Content-Transfer-Encoding: binary\n");
Upvotes: 4