Zip Files

I am trying to download a zip file through a link in my email. Sometimes it downloads and sometimes it doesn’t.
I am wondering if server settings has something to do with it?
any help would be appreciated. Thanks

Is this zip file stored on your server? Is it served by a PHP script?

When you say it doesn’t work - what happens?

If the zip file already has contained in server may not work.

Since zipfiles are large my first guess is you’re hitting the file_upload limit. The default setting is only 2MB. Check your configuration.

@r2d2
Yes it is on our server and I have made it through php script
require_once(‘class.zip.php’);
$zipfilename = ‘zipfiles/productName.zip’;
When I say it doesn’t work I mean that if I download the zip file through FTP it downloads fine. And if I download it through the link that I get after buying the product, it downloads sometimes half and some time few bytes and sometimes it download the whole file perfectly.

@frworkbd
sorry didn’t get you…

@Michael Morris
No I am not uploading it. Plus file_upload limit for the server is 20MB and the zip file I am trying to download is 5MB. The file is already on the server, actually I make this zip file through PHP. And it downloads fine through FTP.

So is the zip file accessed directly on the server, or through the PHP script? I guess if you’re also accessing via FTP, then you are accessing it directly. Have you tried using a known ‘good’ zip file, rather than one created by your PHP script?

Is the difference between download success and fail the browser used? For example, IE requires you send the file’s size as one of the headers for downloading to work.

@r2d2
No i haven’t tried any other zip other then made by the PHP script, but the problem is it does work sometimes.
The code i use for downloading is

	if($db->col["digi_console"] == 'Yes'){
		$filename = "./zipfiles/".$db->col["product_id"].".zip";
	}else{
		$filename = "./content/download/".$db->col["digital_product_file"];
	}
	
	header("Pragma: public");
	header("Expires: 0"); // set expiration time
	header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
	
	header("Content-Type: application/force-download");
	header("Content-Type: application/octet-stream");
	header("Content-Type: application/download");

	header("Content-Disposition: attachment; filename=".basename($filename).";");

	header("Content-Transfer-Encoding: binary");
	header("Content-Length: ".filesize($filename));
	if( !ini_get('safe_mode') )
		set_time_limit(360000000);
	
	readfile("$filename"); 
	
	exit();

@Michael Morris
I have tried on the firefox and does work sometimes.

https connection by any chance??

Internet Explorer Can’t Open Files Via HTTPS: Try Removing The Pragma Header - Mark S. Kolich

I just use this for created downloads via PHP:


		header("Content-Disposition: filename=$file");
		header("Content-type: application/octet-stream");
		readfile($file);

Perhaps try removing some of the other header calls you have?

@Michael Morris
I am not using HTTPS , but see the thing is I checked it on Firefox and chrome and it did downloaded the whole thing sometimes. So i am wondering if this has something to do with the bandwidth or server settings? just confused…

@r2d2
Same problem it did worked the first time but then didn’t work anymore. I also tried to remove header calls but of no use.

To rule out bandwidth or server policy issues test the script on your local machine using XAMPP