I'm trying to write a cgi script to allow file uploads. I can't seem to get upload() to define my filhandle scalar. I am able to write $filename to the upload directory but it conatains 0K size.
The documentation says that upload uses /tmp, /usr/tmp and then where the script is to write the temporary file that the filehandle links to.
I just don't see what I'm missing, this looks and seems pretty straight forward.
Thanks for any and all help
Joe
Code Snipet:
#!/usr/bin/perl -w
use strict;
use CGI;
my $formdata = CGI->new;
my $file = $formdata->param('file');
my $filename = $formdata->param('filename');
my $fh = $formdata->upload($file);
print STDERR "$file\n";
print STDERR "$filename\n";
if (defined $fh){<br>
print STDERR "\$fh is defined\n";
}
Apache Error Log:
test.jpg
new_test.jpg
[Sat Nov 1 17:49:29 2003] [error] [client 127.0.0.1] Premature end of
+ script headers: /var/www/cgi-bin/eface/clients.pl
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.