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


In reply to Re: Re: Re: Yet another CGI Upload problem - not like the others! by tachyon
in thread Yet another CGI Upload problem - not like the others! by stuayres

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.