Skip to content

Instantly share code, notes, and snippets.

@mcnaveen
Last active March 15, 2021 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcnaveen/b17232f41764f253082fc464502dfc32 to your computer and use it in GitHub Desktop.
Save mcnaveen/b17232f41764f253082fc464502dfc32 to your computer and use it in GitHub Desktop.
PHP Download ZIP file and Hide Download URL
<?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