Re: CGI File Upload Problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 27, 2004 at 03:06:40PM +0800, Raxie wrote:
> 
> Here's the upload portion of the code. $fh is the file being
> uploaded that came from the form.
> 
>         if ($line=<$fh>) {  --> THIS IS THE LINE THAT IS HAVING A PROBLEM
> UNDER FEDORA BUT WORKS UNDER RH9
> 
>           my $fexists=scalar(stat($CURRENT_FOLDER.$new_filename));
>           if (open(FILE,">$CURRENT_FOLDER$new_filename")) {
>               print FILE $line;
>               while ($line=<$fh>) {
>                   print FILE $line;
>               }
>               close(FILE);

I cannot tell if the error is input or output yet.  All I know is that
a file results in zero bytes.  Perhaps the input is zero bytes.  The
print prior to the while could stuff some "HereIam" in FILE.  
I am curious what $line might be pror to the while() loop.

Perhaps print or test  the status of $fh...  no input no output
in your loop  and that is what you see.

What if the while loop  looked more like:
     while (<$fh>) {
	   # add a debug print here to see if the loop loops even 1 time.
	   $line=$_;
	   print FILE $line;
	   }

It might be valuable to specify the first line of your
CGI script.   I assume it is perl5 (perl-5.8.3-18).
Not all CGI is perl.

A google search found this URL and code fragment...

  http://stein.cshl.org/WWW/software/CGI/#download

=== begin quote ==
RETRIEVING CGI ERRORS

Errors can occur while processing user input, particularly when
processing uploaded files. When these errors occur, CGI will stop
processing and return an empty parameter list. You can test for the
existence and nature of errors using the cgi_error() function. The
error messages are formatted as HTTP status codes. You can either
incorporate the error text into an HTML page, or use it as the value
of the HTTP status:


    my $error = $q->cgi_error;
    if ($error) {
	print $q->header(-status=>$error),
	      $q->start_html('Problems'),
              $q->h2('Request not processed'),
	      $q->strong($error);
        exit 0;
    }

=== end quote ==


-- 
	T o m  M i t c h e l l 
	Just say no to 74LS73 in 2004



[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux