Jump to content

Hidden Download URL --> Invalid ZIP


supm

Recommended Posts

Hi, I'm trying to implement the following code that I found at http://www.actionscript.org/forums/showthread.php3?t=83105

 

$fileToDownload = "path/to/your_file.zip"; 

header("Pragma: public"); 
header("Expires: 0"); 
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
header("Cache-Control: private",false); 
header("Content-Type: application/zip"); // you can put here MIME type of your file 
header("Content-Disposition: attachment; filename=\"" . basename($fileToDownload) . "\";" ); 
header("Content-Transfer-Encoding: binary"); 
header("Content-Length: ".filesize($fileToDownload)); 
set_time_limit(0); 
readfile("$fileToDownload");  

 

This is a script that supposedly masks the actual URL paths of downloadable files so they can't be as easily redistributed. I have searched elsewhere on the web and have found many variations of this script.

 

Unfortunately, none of these scripts worked properly.

 

The files concerned are ZIP files. When accessing a ZIP file via one of the scripts concerned, it seems to download fine, as the file name and size is retained upon completion of download. However, when attempting to open or extract the ZIP file, error messages pop up noting that the ZIP file is either invalid or empty. (I have tried echoing the actual path to confirm that the download is coming from the correct location, and it is.)

 

Contrarily, when I download a ZIP file by navigating to the actual URL, the file is extractable and not declared empty.

 

I have tried on various browsers, including the latest versions of Firefox and Chrome.

 

Any ideas? Is it perhaps an issue with the hosting service?

Link to comment
https://forums.phpfreaks.com/topic/229024-hidden-download-url-invalid-zip/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.