Jump to content

download a zip


jasonc

Recommended Posts

i wish to have my visitors download a zip file of all documents for our meetings but the download is not working.

 

i am using the $_GET method to get the date of the meetings.

if (isset($_GET['da'])) {
$articledate = stripstring($_GET['da']);
$zipfile =  $fileprefix . substr($articledate, 0, 2) . "-" . substr($articledate, 2, 2) . "-" . substr($articledate, 4, 4) . " - Agenda.zip";
$zipfiletoDL = "agendas/" . $zipfile;
		if (! file_exists($uploaddir . "/" . $zipfiletoDL)) {
		// outputting a download link
		header('Content-type: application/zip');

		// It will be called downloaded.zip
		header('Content-Disposition: attachment; filename="' . $zipfile . '"');

		// The ZIP source is in original.zip
		readfile($uploaddir . $zipfiletoDL);
		//echo($siteurl.$filename);
		} else {
		?>File does not exist.<?
		}
}

i have altered my original PDF download script to this and changed the PDF's to ZIP's but still the download load will not work

 

how do i correctly have my visitors download the file using the $_GET method ?

Link to comment
https://forums.phpfreaks.com/topic/181592-download-a-zip/
Share on other sites

part solved...

 

		// Headers for an download:
		header('Content-Type: application/octet-stream');
		header('Content-Disposition: attachment; filename="'.$zipfile.'"'); 
		header('Content-Transfer-Encoding: binary');
		// load the file to send:
		readfile($uploaddir . $zipfiletoDL);

 

but now the file is not found for some reason, i think it is the spaces in the file name but i ned these spaces for the rest of the site to work correctly.

 

any ideas why it is how finding the file?

 

using file_exisit() error it says file does not yet the file to be found it the correct link?

 

'/home/site/public_html/my file name.zip'

Link to comment
https://forums.phpfreaks.com/topic/181592-download-a-zip/#findComment-957906
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.