perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel <embp...@7thfire.com>
Subject Re: Empty file uploads
Date Tue, 01 Mar 2005 00:04:43 GMT
Hi,

I'm using this syntax:

<FORM METHOD="POST" ENCTYPE="multipart/form-data">
<INPUT TYPE="FILE" NAME="IDPD_File" size=60>
</form>

    my $buffer;
    if  (open FILE, "> $tmpFile") {
        print FILE $buffer while read($$fdat{file}, $buffer, 32768);
        close FILE;                                            
    }

I don't seem to have any problems with this. Perhaps you could try this
method instead?

db


On Tue, Mar 01, 2005 at 10:53:46AM +1100, Robert Norris wrote:
> 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.



-- 
"Those who would give up essential Liberty, to purchase a little temporary
Safety, deserve neither Liberty nor Safety." -- Benjamin Franklin

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Mime
View raw message