Strange problem when downloading file from MySql DB

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
AnAlienHolakres3
Forum Newbie
Posts: 3
Joined: Sat Nov 01, 2008 6:58 am

Strange problem when downloading file from MySql DB

Post 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;                                          
 
 
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: Strange problem when downloading file from MySql DB

Post 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
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
AnAlienHolakres3
Forum Newbie
Posts: 3
Joined: Sat Nov 01, 2008 6:58 am

Re: Strange problem when downloading file from MySql DB

Post 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....
AnAlienHolakres3
Forum Newbie
Posts: 3
Joined: Sat Nov 01, 2008 6:58 am

Re: Strange problem when downloading file from MySql DB

Post 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:
Post Reply