473,498 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Corrupted ZIP files during download via PHP

Hello,

I am posting this rather lengthy description here in hope of getting at
least some insight into a problem that is really hurting my business,
since I have come to the conclusion that my problem is at least partly
PHP-related.

Some time now I have been having transfer problems, i.e. my customers
downloads of large binary (ZIP) files are often corrupt.

A corrupted file now and then can of course never be avoided, but I get
several complaints from customers every day. Of any specific file,
approx. 1 out of 4 downloads (larger than 100kB or so) are affected.
I have spent months trying to find the source of the problems without
success, but I have been able to rule out many possible causes. Here are
some facts:

1) The actual files are OK on the server. Direct (unencrypted) links are
fine, so it's not a general problem.

2) About 50% of the customers download (the exact same files) from
another source. I don't even get 1 complaint every two months from those
customers, while I get 1-3 complaints _every day_ from those who
download from my server.

3) The customers have various SW/HW/OS, so it's very unlikely that it's
a user problem. Plus, the same customer often download from both places,
but only have problems with the files from my server.

4) I have shut down all scripts for a while, so that only a static
website remained, but it didn't help.

5) I have had this problem on three servers: The present RaQ550, the
previous RaQ4 and the RaQ4 I had before that. So it's highly unlikely
that it is server-related.

6) I can easily reproduce the problem myself. As I looked into this I
found a systematic error:

Analyzing corrupt vs. clean ZIP file downloads with a binary/hex editor
clearly shows that the error is systematic. Clean ZIP files have a lot
of '00h' bytes in them. In ALL of the corrupt ZIP files ALL (well, most)
of these bytes have been exchanged for '5C30h', i.e. TWO bytes ( 00h ->
5C30h ) !

Since '5C30h' equals an escaped zero, i.e. "\0", my guess is that there
is a translation error somewhere.

So, what does PHP have to do with this? Well, my download links to
purchaseware are encrypted by the PHP "ewportal":
http://www.eliteweaver.co.uk/antifra....php?page=Home

From the few facts I have been able to uncover it seems there is
sometimes a problem with corrupted ZIP files depending on the
setting/compilation of ZLIB. If anyone on this forum have experienced
similar things I would very much appreciate if they could share.
My servers PHP configuration is at:
http://www.snith.com/phptest.php

Best regards, Lars
Jul 17 '05 #1
12 5406
*** Swede escribió/wrote (Tue, 15 Feb 2005 21:16:18 +0100):
Some time now I have been having transfer problems, i.e. my customers
downloads of large binary (ZIP) files are often corrupt.
I suggest that you check the server's MIME type for *.zip files.

From the few facts I have been able to uncover it seems there is
sometimes a problem with corrupted ZIP files depending on the
setting/compilation of ZLIB.


Do you compress the files on the fly?
--
-+ Álvaro G. Vicario - Burgos, Spain
+- http://www.demogracia.com (la web de humor barnizada para la intemperie)
++ Manda tus dudas al grupo, no a mi buzón
-+ Send your questions to the group, not to my mailbox
--
Jul 17 '05 #2
Hello Alvaro,

Alvaro G. Vicario wrote:
*** Swede escribió/wrote (Tue, 15 Feb 2005 21:16:18 +0100):
Some time now I have been having transfer problems, i.e. my customers
downloads of large binary (ZIP) files are often corrupt.


I suggest that you check the server's MIME type for *.zip files.


I have already tried that, it was set to some non-descript application.
I changed it to "octet-stream" together with "*.exe" and the other
binaries, but it did not help. Is there any more place than "mime.types"
where I could change this?

I have seen some brief comments about "commenting out the header which
gets the mimetype of the file in class.download.inc", but I have no idea
how/where to do that, and if it is related to my problem.
From the few facts I have been able to uncover it seems there is
sometimes a problem with corrupted ZIP files depending on the
setting/compilation of ZLIB.


Do you compress the files on the fly?


Not intentionally...they are already ZIPs on the server disk.

Thanks for your input so far, I think you are definitely on the right
path! Any more good ideas?
Best regards, Lars
Jul 17 '05 #3
*** Swede escribió/wrote (Tue, 15 Feb 2005 21:52:39 +0100):
I have already tried that, it was set to some non-descript application.
I changed it to "octet-stream" together with "*.exe" and the other
binaries, but it did not help. Is there any more place than "mime.types"
where I could change this?


My suggestion only came because maybe the server was using the default type
(usually text/html) and was messing with character encoding or God knows
what.

Anyway, since you seem to be using a PHP script to serve files then it's
the script the one who should be setting the MIME type; otherwise you'll
get the default type. Something similar to this should do:

header('Content-Type: application/zip');

Internet Explorer is known for having problems with PDF files (esp. if you
use sessions) but I'm not sure about ZIPs.

--
-+ Álvaro G. Vicario - Burgos, Spain
+- http://www.demogracia.com (la web de humor barnizada para la intemperie)
++ Manda tus dudas al grupo, no a mi buzón
-+ Send your questions to the group, not to my mailbox
--
Jul 17 '05 #4
Hello Again,

Alvaro G. Vicario wrote:
*** Swede escribió/wrote (Tue, 15 Feb 2005 21:52:39 +0100):
I have already tried that, it was set to some non-descript application.
I changed it to "octet-stream" together with "*.exe" and the other
binaries, but it did not help. Is there any more place than "mime.types"
where I could change this?
My suggestion only came because maybe the server was using the default type
(usually text/html) and was messing with character encoding or God knows
what.

Anyway, since you seem to be using a PHP script to serve files then it's
the script the one who should be setting the MIME type; otherwise you'll
get the default type. Something similar to this should do:

header('Content-Type: application/zip');


Sounds like a good idea, should this go into "php.ini", or in the script
itself ?

Internet Explorer is known for having problems with PDF files (esp. if you
use sessions) but I'm not sure about ZIPs.


Yes, IE causes a lot of problems, but I see this also on my Mozilla/Firefox.
Best regards, Lars
Jul 17 '05 #5
The conversion of binary zeros to "\0"s is consistent with
magic_quotes_runtime = On.

Jul 17 '05 #6
*** Swede escribió/wrote (Tue, 15 Feb 2005 22:15:08 +0100):
header('Content-Type: application/zip');


Sounds like a good idea, should this go into "php.ini", or in the script
itself ?


Maybe it's a good idea not to mess with this if you are unsure of what it
does. This is just PHP code, not a configuration directive. How to use it
depends on how your script is coded.
Internet Explorer is known for having problems with PDF files (esp. if you
use sessions) but I'm not sure about ZIPs.


Yes, IE causes a lot of problems, but I see this also on my Mozilla/Firefox.


If you use Firefox, please install the "Live HTTP Headers" extension and
find out yourself what MIME type is used.

--
-+ Álvaro G. Vicario - Burgos, Spain
+- http://www.demogracia.com (la web de humor barnizada para la intemperie)
++ Manda tus dudas al grupo, no a mi buzón
-+ Send your questions to the group, not to my mailbox
--
Jul 17 '05 #7
Hello,

Thanks for the tip. Unfortunately all of magic_quotes_gpc,
magic_quotes_runtime, magic_quotes_sybase are "off" in the php.ini, so
this should not be the cause as far as I can understand.

Best regards, Lars

ch***********@hotmail.com wrote:
The conversion of binary zeros to "\0"s is consistent with
magic_quotes_runtime = On.

Jul 17 '05 #8
Hello Alvaro,

Thanks for your input, I really appreciate it!
Unfortunately the script is not my own to start with, I do many
languages but have not got around to PHP yet. I will try it out
(reversible...). But it will have to be tomorrow, it's bedtime for me
here now (Norway)!

Best regards, Lars
Alvaro G. Vicario wrote:
*** Swede escribió/wrote (Tue, 15 Feb 2005 22:15:08 +0100):
header('Content-Type: application/zip');


Sounds like a good idea, should this go into "php.ini", or in the script
itself ?

Maybe it's a good idea not to mess with this if you are unsure of what it
does. This is just PHP code, not a configuration directive. How to use it
depends on how your script is coded.

Internet Explorer is known for having problems with PDF files (esp. if you
use sessions) but I'm not sure about ZIPs.


Yes, IE causes a lot of problems, but I see this also on my Mozilla/Firefox.

If you use Firefox, please install the "Live HTTP Headers" extension and
find out yourself what MIME type is used.

Jul 17 '05 #9
Don't know if it would help in this case, but Igor Tandetnik's
PassThruAPP is very useful for diagnosing IE issues:

http://home.nyc.rr.com/itandetnik/passthruapp.zip

Jul 17 '05 #10
DH
Swede wrote:
So, what does PHP have to do with this? Well, my download links to
purchaseware are encrypted by the PHP "ewportal":
http://www.eliteweaver.co.uk/antifra....php?page=Home


Try using WinZip or similar application to make the ZIP files and see if
the problem goes away. I've been using eliteweaver for almost 2 years,
problem free (aside from some really ugly code), although my downloads
were all compiled using WinZip.
Jul 17 '05 #11
Thanks! I'll have a look at it! /Lars

ch***********@hotmail.com wrote:
Don't know if it would help in this case, but Igor Tandetnik's
PassThruAPP is very useful for diagnosing IE issues:

http://home.nyc.rr.com/itandetnik/passthruapp.zip

Jul 17 '05 #12
DH wrote:
Swede wrote:
So, what does PHP have to do with this? Well, my download links to
purchaseware are encrypted by the PHP "ewportal":
http://www.eliteweaver.co.uk/antifra....php?page=Home

Try using WinZip or similar application to make the ZIP files and see if
the problem goes away. I've been using eliteweaver for almost 2 years,
problem free (aside from some really ugly code), although my downloads
were all compiled using WinZip.


Thanks for the tip! Unfortunately this is how I have done it all the
time. /Lars
Jul 17 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
6078
by: Brandon Walters | last post by:
I wrote a file download module for my website. The reason for the file download module is that my website downloads work on a credit based system. So I need to keep track of and limit daily...
3
2196
by: r.e.s. | last post by:
No matter which site I download it from, NumTut.tgz appears to be corrupted. Anyone else having this problem? Thanks. -- r.e.s.
0
1771
by: Anup Jishnu | last post by:
Hi, I have installed ASP.Net application on a system. When accessing the Application from within the LAN, it works fine. However, when I access the application from the Internet, some pages...
6
1477
by: vmrha | last post by:
I just downloaded the file 414465677 Jun 5 16:15 LNX26_V822_PE_x86-64.tar from the IBM Web DB2 web site, and it looks like the file is corrupt. N. Shamsundar University of Houston...
28
4016
by: Lee Rouse | last post by:
Hello all, This is going to be a rather lengthy "question". I have an Access 2k database, separated front end/back end. Front end copies are on about 30 workstations and used frequently during...
0
1489
by: Owen Jenkins | last post by:
I've been using Dev's fantastic InetTransferLib to upload and download files via ftp. Now I'm using the http procedures to have my application download zip files from my website. Although the...
1
2226
by: Owen Jenkins | last post by:
Reposting this message from last week since I have not had a reply so far. Hopefully someone will have an idea? --- I've been using Dev's fantastic InetTransferLib to upload and download files...
7
2522
by: jc | last post by:
i'm developing a project using vc++. the main exe is a win32 application. it needs two dlls. one is my own implementation of string operations. the other dll is to parse a2l files(it is similar to...
6
6321
by: phpmagesh | last post by:
Hi I have tried this sample code in my database for file update, but some error occurred. everything is going fine. uploaded the file successfully but, when i download the file which i...
0
7002
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5462
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4908
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4588
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
290
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.