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
Share on other sites

Update: I opened the ZIP file in Notepad++ and discovered that HTML was mixed in.  In fact, it seems that most if not all of the HTML of the webpage that feeds the ZIP file content somehow got mixed into the ZIP file itself.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.