View Single Post
  #4 (permalink)  
Old 05-04-2008, 05:54 AM
jaguar jaguar is offline
Newbie
 
Join Date: May 2008
Posts: 2
Rep Power: 0
jaguar is on a distinguished road
Default Re: File download is corrupted

WingedPanther: Yes, I have tried downloading with with Firefox for ubuntu, windows and mac. Same thing happens with IE7 and safari. And yes i have verified that the file is not corrupt on the server because if i move it outside the protected directory, the download is fine.

Jordan: thanks for the advice. because i'm selling downloads, i dont want anyone having a direct URL to them. that is why i'm using this script (which is part of virtuemart, btw) and a protected directory. all the files are of similar size.

I just checked if there is an error message appended to the downloaded file, there is none. the file sizes are slightly different though, the downloaded file is smaller.

Here is the code where i construct my headers (again, from virtuemart). it is very similar to the example you posted.

PHP Code:
$datei DOWNLOADROOT $file_name;
// dump anything in the buffer
@ob_end_clean();

header('Content-Type: ' $mime_type);
header('Expires: ' gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Length: ' filesize($datei) );

if (
$UserBrowser == 'IE') {
    
header('Content-Disposition: attachment; filename="' $file_name '"');
    
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    
header('Pragma: public');
} else {
    
header('Content-Disposition: attachment; filename="' $file_name '"');
    
header('Pragma: no-cache');
}
/*** Now send the file!! ***/
vmReadFileChunked$datei ); 
i guess that the strangest thing is that all the code works for every other zip file i have. why should this particular one become corrupt?
Reply With Quote