Last active
March 15, 2021 17:14
-
-
Save mcnaveen/b17232f41764f253082fc464502dfc32 to your computer and use it in GitHub Desktop.
PHP Download ZIP file and Hide Download URL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$path = 'file.zip'; //Path to File | |
$filedownloadname = 'downloadfilename.zip'; //File Name when downloading | |
header("Pragma: public"); | |
header("Expires: 0"); | |
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); | |
header("Cache-Control: public"); | |
header("Content-Description: File Transfer"); | |
header("Content-Type: " . $mime_type); | |
header('Content-Disposition: attachment; filename="'. $filedownloadname .'"'); | |
header("Content-Transfer-Encoding: binary\n"); | |
readfile($path); | |
exit(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment