perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Norris <>
Subject Empty file uploads
Date Mon, 28 Feb 2005 23:53:46 GMT
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' />

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

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

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

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


View raw message