Page 1 of 1

Strange problem when downloading file from MySql DB

Posted: Sat Nov 01, 2008 8:02 am
by AnAlienHolakres3
Hello everyone, i wonder if anyone has a clue to solve following situation:
- when i download certain (zip) file by download manager, its size is exactly the same as original file , these files are identical
- when i download the same file by browser (no matter of what...IE,Firefox,Opera..), download file is incomplete (a few bytes missing so zip file is ocrrupted)

I found out that if header content-length is NOT used, then downloaded file is complete in both downlad managers and internet browsers, however without showing filesize and estimation download time.

Is there any way how to fix that?

Code: Select all

 
      $name = utf8_decode($file->taskfile_name);      
      $name = str_replace(' ','_',$name);                 
      $type = "application/octet-stream";  
     // $type = "application/zip";  
      $size = $file->taskfile_size;
      $content = $file->taskfile_content;
 
      ob_clean(); //veeery important!! without that some empty lines will be added before output...
       
       //header("Content-length: $size ");
       header("Content-type: $type ");   
       header("Content-Description: VSElink team file");
       header("Content-Disposition: attachment; filename=$name");       
       echo $content;         
       exit;                                          
 
 

Re: Strange problem when downloading file from MySql DB

Posted: Sat Nov 01, 2008 5:21 pm
by s.dot
echo your size to see if it is what it should be. If it's not, investigate the size determination method ;p

Re: Strange problem when downloading file from MySql DB

Posted: Sun Nov 02, 2008 5:06 am
by AnAlienHolakres3
scottayy wrote:echo your size to see if it is what it should be. If it's not, investigate the size determination method ;p
Thanks but...the size is exactly what is supposed to be....

Re: Strange problem when downloading file from MySql DB

Posted: Mon Nov 03, 2008 1:25 pm
by AnAlienHolakres3
Finally found the solution! By analyzing packets in Wireshark i found line
"CONTENT-ENCODED ENTITY BODY (GZIP): 37342 BYTES -> 37322 BYTES "

Using GZIP was not intentional, so i edited .HTACCESS file to disable it and now it works smoothly. Hope it helps someone. :mrgreen: