Hi,
Ok.. i have some pages on my site that has a link like
<A HREF="<?php $websiteaddress ?>/webbuilder/downloads/download.php?filename=age_verification_popup.zip">Download</A>
if you look carefully you will see using get in my below script i get the filename in this example age_verification_popup.zip
This is then sent to this script.
<?php
@include ("/home/sites/genieuk.co.cc/public_html/includes/global.php");
// check if member is logged in before issuing file. Function in global.php
memberonlyzoneerror(); // if user not logged in the function exits and Does Not carryon with script.
// get filename
$getfile = $_GET['filename'];
// path to file
$filepath = '/home/sites/mydomain.co.cc/public_html/webbuilder/downloads/files/'.$getfile.'';
// check file exisits, if it does force download/header
if ( file_exists( $filepath ) ) {
// Headers
header('Content-type: application/zip');
header('Content-disposition: attachment; filename='.$getfile.'');
header("Content-length: " . filesize( $getfile ));
} else { // else if file does not exist tell them and exit.
@include ("/home/sites/mydomain.co.cc/public_html/includes/webbuilder_top.inc");
echo "<h2> File Does Not exist </h2>";
echo "<p> The file you have requested does not exist. If you feel you received this message in error, please contact us.</p>";
redirect ("web_builder_download_extensions_templates.php", "3");
@include ("/home/sites/mydomain.co.cc/public_html/includes/footer.inc");
exit;
}
?>
I removed my actual domain as site is not live yet and don't want it revealed. Problem i am having is that when i click link to download it works like it suppose to, passed file name to download.php and then download.php to do it' work, it DOES download the file requested but the file seems empty as when i try and open in Windows Vista using WinRAR i get:
The archive is either in unknown format or is damaged. Now i downloaded file via ftp and it opens so definately not the zip file.
I am at a loss why this is not working for me. Directories etc is correct and fine of course as it downloads etc.
I get no errors or anything, i am sure i am missing something really simple or just not doing something correctly.
I did have file_get_contents in the script but dont think it was needed as after reading about it, it seems only fine if opening/reading the file, althou i did try incase and it did not work that way either.
Can someone please tell me what i am doing wrong please as i am at a complete loss. Been try to figure out what i been doing wrong for hours with no luck.
Thank you,
Mat