To anyone who can help the lowly: I am trying to have a simple upload script that is activated by a LWP script. The Web server is Apache 2 on Windows and the script looks like this:
use strict; use CGI; my $q=CGI->new(); my $client = $ENV{'REMOTE_ADDR'}; my $buffer; my $file = $q->param('upload_file'); $client =~ s/\./_/g; open(FH,"> c:/upload/$client.txt") or die($!); my $fh = $q->upload('upload_file'); while (<$fh>) { print FH; } close(FH); close(LOG);
This is the script that invokes the server script:
#!perl -w use LWP::UserAgent; use HTTP::Request::Common qw/POST/; my $ua= LWP::UserAgent->new(); my $filename= $ARGV[0]; chomp($filename); my $url='http://diesel.nci.nih.gov/cgi-bin/store.pl'; my %fields = ("upload_file" => "$filename"); my $results = $ua->post($url , content => [upload_file => "$filename"], enctype => 'multipart/form-data'); if($results->is_success){ print "It's good!\n"; } else { print "It didn't work.\n"; print $results->status_line(); }
The output from the web server is:
50:34 2004] [error] [client 156.40.134.176] Use of uninitialized value + in <HANDLE> at C:/Apache/scripts/store.pl line 19. [Wed Nov 10 13:50:34 2004] [error] [client 156.40.134.176] readline() +on unopened filehandle at C:/Apache/scripts/store.pl line 19.
The filename is create on the server but it is o bytes long. Does anyone have any ideas on why it isn't working? Any information is appreciated. tcox

In reply to CGI Uploading Trouble by tcox

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.