Hi,
I got some zip files on my server people can download and am having a strange problem.
Can't remember if i ever checked in IE but in FireFox, Google Chrome, Opera everything is fine.
When i download a file from my website in IE the file is getting corrupt.
I extract the files with winzip and some say corrupt/damaged file and some extracts and inside it shows the filename and filetype as file.
I uploaded in binary and via host account, overwritten them to ensure they are not corrupt and still getting the same problem.
I was notified by a user that when it got to 99% in downloading that it would stop and do nothing. I am still awaiting what browser they was using. Thing is i can download them but they seem corrupt or will open but will show a file inside that says it is just a file and windows does not know how to open it.
It seems in all browsers that when i download that the last KB/MB seems to take about 3 seconds to finish like if there is a delay for a second or so although not sure if that is just my virus scanner etc checking the file once downloaded.
Below is the script that i developed some time ago that processes the download.
Can someone tell me if they see something wrong? IE seems to get the file size wrong, if i got a file for example 1.12MB once downloaded it shows as 1.11MB.
I also noticed in Opera that Opera cannot detect the file size at all.
As i say i have not had problems before, i also tried downloading from other sites in IE etc and they downloaded and opened fine. I have noticed that Opera seems to change the file names to download.zip, i don't user Opera so not sure if this is suppose to happen or not. I guess it could be a problem with more than one browser, FireFox, Google Chrome and Opera thou do download them and they open and show as they should. Very confused.
I am pretty desperate to get this sorted.
Thanks
PHPLOVER
<?php
include ("".$_SERVER['DOCUMENT_ROOT']."/includes/global.php"); // include global file
require_once("".$_SERVER['DOCUMENT_ROOT']."/includes/session.php"); // include session
memberonlyzoneerror(); // check if user is logged in
if( isset( $_GET['filename'] ) ) {
// get filename
$getfile = $_GET['filename'];
// path to file
$filepath = "/path/to/file/here/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-Transfer-Encoding: binary");
header("Content-length: " . filesize( $filepath ));
readfile($filepath);
} else { // else if file does not exist tell them and exit.
@include ("".$_SERVER['DOCUMENT_ROOT']."/includes/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 ("downloads.php", "3");
include ("".$_SERVER['DOCUMENT_ROOT']."/includes/footer.inc");
exit;
}
} else {
@include ("".$_SERVER['DOCUMENT_ROOT']."/includes/top.inc");
echo "<h2> Missing an important parameter </h2>";
echo "<p>You have used a false link, this page is missing an important parameter. Please report this to Genieuk.</p>";
redirect ("downloads.php", "8");
include ("".$_SERVER['DOCUMENT_ROOT']."/includes/footer.inc");
exit;
}
?>
Thanks