httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Allen <>
Subject File corruption on HTTP upload
Date Thu, 20 Jun 2002 11:43:14 GMT
Dear Apache users,

I run a web site which allows customers to upload and store photographs
as jpeg images.

The site uses a simple perl CGI script to upload multiple files from a HTML

Most of the time everything works fine, but occasionally files will get corrupted
in a bizarre way. The file sizes remain correct, but blocks of data, usually of
about 4K or so in size, get shifted around within the files. Sometimes it will
be a direct swap of one block for another one, and sometimes a block from
later in the file will overwrite a block from earlier in the file.

Things I have found so far:

- Our web server is Apache 1.2.23 with mod_proxy and mod_ssl

- The system is a Sun E220 with Solaris 7.

- Some users *never* see this problem, despite gigabytes of uploads. Others
see it semi-consistently (perhaps 1 in 50 uploads). When bad, they will see
it for several uploads in a row.

- Users who see this problem are all on broadband ADSL connections

- On a page of multiple uploads, if one file gets corrupted, all of the
files will get corrupted

I am *totally* perplexed by this. I can find no obvious reason for it, nor
does the corruption seem to be triggered by anything in particular.

If anybody else has seen this problem, I'd be *very* glad to hear from you!

I have attached the guts of the Perl script that does the uploads. I would be
surprised if such a subtle corruption problem was due to this, but am open
to suggestions.

I have also uploaded a couple of corrupt files to the web: - is good - is the same file corrupted - is good - is the same file corrupted

Many thanks,

Chris Allen

#!/usr/bin/perl -w

use CGI ();
use cj;
use phdb;


@uploads=grep /^c_photo/,$c->param();
foreach $upload (@uploads)
        my $buffer;
                open(FH,">$upload_quantity.dat") or cj->bail_out();
                print FH $buffer while read($file, $buffer, 1024) or cj->bail_out();
                close FH;

print $c->redirect("/album/upload_thanks.html?n=$upload_quantity");

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message