in reply to Re: Re: Yet another CGI Upload problem - not like the others!
in thread Yet another CGI Upload problem - not like the others!
To debug this change the die to die $query->cgi_error()
If that is not revealing then have a look at the CGI object which should contain a blessed? reference to the upload file's tmpdir name.
use CGI; use Data::Dumper; $q = new CGI; print $q->header; print '<pre>' . $q->escapeHTML(Data::Dumper::Dumper($q)) . '</pre>';
This will prove one way or another if the file is getting to the server and being written to a tmp dir. This may well be the problem. When you do the upload the file is spooled by CGI.pm to a tmp dir ( CGI.pm uses /tmp /temp and something else in that order from memory). If it can't write here it can't spool. Then when you call upload() it will have nothing to deliver and return false, thus causing death as described.
If that fails then try my CGI::Simple module which has the same interface as CGI.pm but far more inclusive and revealing cgi_error() messages. It uses IO::File's tmpfile() method to get a FH for spooling so does not need write permission to /tmp. It also has an addition to the upload() method that lets you do the upload in one line. See the docs for details.
use CGI::Simple; my $q = new CGI::Simple; # <INPUT TYPE="file" NAME="upload_file" SIZE="42"> $files = $q->upload() # number of files uploaded @files = $q->upload(); # names of all uploaded fi +les $filename = $q->param('upload_file') # filename of uploaded fil +e $mime = $q->upload_info($filename,'mime'); # MIME type of uplo +aded file $size = $q->upload_info($filename,'size'); # size of uploaded +file my $fh = $q->upload($filename); # get filehandle to read f +rom while ( read( $fh, $buffer, 1024 ) ) { ... } # short and sweet upload $ok = $q->upload( $q->param('upload_file'), '/path/to/write/file.n +ame' ); print "Uploaded ".$q->param('upload_file')." and wrote it OK!" if +$ok;
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Yet another CGI Upload problem - not like the others!
by zentara (Cardinal) on Dec 11, 2002 at 19:17 UTC | |
by tachyon (Chancellor) on Dec 15, 2002 at 01:27 UTC | |
by fireartist (Chaplain) on Sep 24, 2004 at 23:17 UTC | |
by tachyon (Chancellor) on Sep 25, 2004 at 01:17 UTC | |
|
Re: Re: Re: Re: Yet another CGI Upload problem - not like the others!
by stuayres (Novice) on Dec 11, 2002 at 15:27 UTC |