![]()  | 
  | 
  | 
| Subject:
Fileupload:  Perl 5.8.6, CGI 3.07. It DID worked in perl 5.6.1
 Category: Computers > Programming Asked by: devanchya-ga List Price: $25.00  | 
Posted:
18 Mar 2005 05:31 PST
 Expires: 19 Mar 2005 17:33 PST Question ID: 496672  | 
Hello all,
I have had to do a very fast switch to a new server for a client. The
new server is running 5.8.6 when the old server was running 5.6.1. The
new server is also running CGI 3.07 when the old one was running
2.752... [Hope this helps]
The problem is, both servers are Cobalt4's with a CGIwrap on them. I
have managed to get the site working 99.9% on the new server except
for the file uploading. The code worked on the old server perfectly,
and I've torn my hair out for 5 hours now trying to figure out why it
is not working.
Here's the code snippet
my $query = new CGI();
my $fh = $query->upload("auth_upload");
if(!defined $fh)
{
 open(OUTFILE,">".ORDERAUTH."w$orderid"."auth"."$type") or
oops('file_write_failed', $!);
 
  while (<$fh>)
  {
print OUTFILE $_;
  } 
 close(OUTFILE);
}
The problem is, $fh (which I've checked a billions ways) is always
coming out empty (undefined) no matter what. It's perfectly defined in
perl5.6.1
when I do a simple param('auth_upload'); the file name does show up correctly.
Any help GREATLY and BEGGINGLY accepted. This is drving me nuts and I
have until Saturday to fix it (when the old server goes bye-bye)
Thank you! | 
  | 
| There is no answer at this time. | 
  | 
| Subject:
Re: Fileupload:  Perl 5.8.6, CGI 3.07. It DID worked in perl 5.6.1
 From: ullfindsmit-ga on 18 Mar 2005 21:37 PST  | 
are you sure on the <FORM .....></FORM> you have the input type to
FILE and not TEXT
also, try using this code to help you debug.
	 use strict;
	 use FileUpload;
	 use CGI qw(-private_tempfiles :standard);
	 use vars qw($q $fu);
	 $q = new CGI;
	 $fu = new FileUpload($cgi->param('ufile'));
	 # The uploaded file's size.
	 $size = $fu->size;
	 # Get the filename.
	 $filename = $fu->orig_filename;
	 # Get the full path of the file.
	 $filepath = $fu->orig_filepath;
	 # Get the characters allowed.
	 @chararr = $fu->allow_char;
	 # Add the characters allowed.
	 @chararr = $fu->allow_char('char1', 'char2');
	 # Get the extensions not allowed.
	 @extarr = $fu->deny_ext;
	 # Add the extensions not allowed.
	 @extarr = $fu->deny_ext('cgi', 'shtml');
	 # Save the uploaded file as the original filename.
	 $byteswritten = $fu->save;
	 # Save the uploaded file by using "newfilename".
	 $byteswritten = $fu->save_as("newfilename");
	 # Get the filehandle's current position.
	 $pos = $fu->get_pos;
	 # Set the filehandle position.
	 $fu->set_pos($newpos);
	 # Read a line.
	 $aline = $fu->get_line;
	 # Read many lines.
	 @lines = $fu->get_lines;
lemme know
-Smit. | 
| Subject:
Re: Fileupload:  Perl 5.8.6, CGI 3.07. It DID worked in perl 5.6.1
 From: devanchya-ga on 19 Mar 2005 17:33 PST  | 
Issue solve.d The issue is that the new CGI's only allow fileupload thorugh the first call of CGI, creating a fake global solved it til a re-write's possible.  | 
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.  | 
| Search Google Answers for | 
| Google Home - Answers FAQ - Terms of Service - Privacy Policy |