perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Norris <Robert.Nor...@its.monash.edu.au>
Subject [RESEND] Empty file uploads
Date Thu, 17 Mar 2005 01:16:10 GMT
[Resending, because I need guidance. I realise that file uploads are
working fine for most people, so I'm not expecting an answer, but I'm
hopeful that someone can tell me where to start looking.]

I've noticed that file uploads don't seem to always work. The uploaded
file appears to come through empty most of the time. Usually it works
after restarting the browser, or the server, but not after that. If I'm
lucky, one request will go through, but thats pretty rare, and there
doesn't seem to be any pattern.

I'm using Embperl 2.0rc2 with Perl 5.6.1.

I have the following code for the form:


<form method='post' enctype='multipart/form-data'>
  File: <input type='file' name='file' id='file' />
  <input type='submit' />
</form>


To read the file, I use the following Perl:


    my $fh = $fdat{'file'};
    my $raw = do { local $/; <$fh> };


(I've noticed that the returned filehandle doesn't always seem to act
like a real filename - certain methods don't always work. This way seems
safe).

Most of the time $raw comes back empty.

Using Data::Dumper on %fdat, I get something like this when it works:


$VAR1 = {
          '-file' => {
                       'Content-Disposition' => 'form-data; name="file"; filename="somefile.txt"',
                       'Content-Type' => 'text/plain'
                     },
          'file' => bless( \*{'Fh::fh00001somefile.txt'}, 'Fh' )
        };


When it fails, I get this instead:


$VAR1 = {
          '-file' => undef,
          'file' => bless( \*{'Fh::fh00001somefile.txt'}, 'Fh' )
        };


It seems that the browser is at least doing the right thing, because the
CONTENT_LENGTH and CONTENT_TYPE environment variables seem to be set
correctly:


  CONTENT_LENGTH = 98542
  CONTENT_TYPE = multipart/form-data; boundary=---------------------------12726745371892987527108562749


Anyone seeing this? Where should be looking to find the solution?

Thanks,
Rob.

Mime
View raw message