You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Michael Stepanov <mi...@francoudi.com> on 2005/05/12 11:51:43 UTC

Strange problem with upload file

Dear all,

I have a strange problem with upload file. It was happened only once but 
I'm afraid that
it can be again.
I have a some form like that:

<form 	name="upload_answer" 
	action="upload.epl"  
	enctype="multipart/form-data" 
	method="post">

Select File:&nbsp; <input 	class="textinput" 
				id="answer_file" 
				name="answer_file" 
				type="file" 
				enctype="multipart/form-data">
</form>


In upload.epl I just get filehandler and use it as method's argument:

my $up_obj = new UploadFile();
$up_obj->upload_file($fdat{answer_file});

At the end inside class I use that file handler:

sub upload_file {
    my $self = shift;
    my $fh = shift || die 'File is not uploaded!';

    while(my $row = <$fh>) {
       die "Length of row should be 80!" unless length($row) == 80;
       . . .
    }
   
    . . .
}  

Recently, I've found in Apache log file that message:
    Warning in Perl code: readline() on closed filehandle 
fh00001C%3A\fts\receive\PBW036H3.023

It seems that file was uploaded but before reading procedure was started 
file handler was closed by
some reason. The strange thing is the loop was run once and program was 
not die in checking of
length of row!

So, does somebody know where Embperl stores uploaded files? Why file 
handler was closed and how check is file handler is open or not?

I use:  - Linux RedHat 9, Embperl/2.0b9, Apache/2.0.40, 
mod_perl/1.99_07-dev, Perl v5.8.0

Thanks in advanced.

-- 
Best regards, 
Michael Stepanov
Perl/Linux Developer
Francoudi & Stephanou Ltd
Tel: +357 25-867154
Email: michaelstepanov@francoudi.com


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


Re: Strange problem with upload file

Posted by Angus Lees <gu...@inodes.org>.
At Thu, 12 May 2005 12:51:43 +0300, Michael Stepanov wrote:
> It seems that file was uploaded but before reading procedure was
> started file handler was closed by
> some reason.
[...]
> I use:  - Linux RedHat 9, Embperl/2.0b9, Apache/2.0.40,
> mod_perl/1.99_07-dev, Perl v5.8.0

Hrm. A problem matching your symptoms exactly was due to a change in
CGI.pm in perl 5.8.3 (and newer).  Embperl was changed in 2.0b11 to
cope.  Do you somehow have a CGI.pm newer than the one shipped with
perl 5.8.0?

Try the most recent version of Embperl and see if that fixes things.

-- 
 - Gus


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


Re: Strange problem with upload file

Posted by Michael Stepanov <mi...@francoudi.com>.
Thanks, Gerald for your quick answer. I've resolved that problem. It's 
related with old version of Embperl and latest version of CGI. You've 
fixed that bug in 2.0b11:  Fixed problem with CGI.pm 3.01+, which 
deletes uploaded files, when CGI object is destroyed.

So, after upgrating Embperl till latest version everithing working fine!

Thanks for very good job!

Gerald Richter wrote:

>Hi,
>
>  
>
>>Recently, I've found in Apache log file that message:
>>    Warning in Perl code: readline() on closed filehandle
>>fh00001C%3A\fts\receive\PBW036H3.023
>>
>>It seems that file was uploaded 
>>    
>>
>
>I guess there was some thumb client (maybe a robot) which pass invalid data
>to your form.
>
>  
>
>>but before reading procedure 
>>was started file handler was closed by some reason. The 
>>strange thing is the loop was run once and program was not 
>>die in checking of length of row!
>>
>>    
>>
>
>No the loop was never run because the expression inside your while is not
>defined and gives the warning above.
>
>  
>
>>So, does somebody know where Embperl stores uploaded files? 
>>    
>>
>
>It's managed by CGI.pm, which creates a temopary file and imediately deletes
>it, so you will never see it.
>
>  
>
>>Why file handler was closed and how check is file handler is 
>>open or not?
>>
>>    
>>
>
>There should be some Perl function to test this, maybe eof() works, but I am
>not sure
>
>Gerald
>
>  
>


-- 
Best regards, 
Michael Stepanov
Perl/Linux Developer
Francoudi & Stephanou Ltd
Tel: +357 25-867154
Email: michaelstepanov@francoudi.com


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


RE: Strange problem with upload file

Posted by Gerald Richter <ri...@ecos.de>.
Hi,

> 
> Recently, I've found in Apache log file that message:
>     Warning in Perl code: readline() on closed filehandle
> fh00001C%3A\fts\receive\PBW036H3.023
> 
> It seems that file was uploaded 

I guess there was some thumb client (maybe a robot) which pass invalid data
to your form.

> but before reading procedure 
> was started file handler was closed by some reason. The 
> strange thing is the loop was run once and program was not 
> die in checking of length of row!
> 

No the loop was never run because the expression inside your while is not
defined and gives the warning above.

> So, does somebody know where Embperl stores uploaded files? 

It's managed by CGI.pm, which creates a temopary file and imediately deletes
it, so you will never see it.

> Why file handler was closed and how check is file handler is 
> open or not?
> 

There should be some Perl function to test this, maybe eof() works, but I am
not sure

Gerald


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