And the client file is:#!perl # Store.pl: sits on a web server waiting to store a file. use CGI; open(LOG,">upload.log"); my $q=CGI->new(); $q->header(); $q->start_html(); my $client = $ENV{'REMOTE_ADDR'}; print LOG "Client: $client\n"; $file = $q->param("upload_file"); print LOG "File: $file\n"; $client =~ s/\./_/g; open(FH,"> c:/upload/$client.txt") or die($!); binmode FH; my $fh = $q->upload($file) or print LOG "Error uploading file $!\n"; print $fh; while (<$fh>) { print FH $_; } $q->end_html(); close(FH); close(LOG);
On the web server the file is created but no data is written. The result message is "500 error" and the error log just says "premature end of script headers." Does anyone have any thoughts?use LWP::UserAgent; $URL_Server = $ARGV[0]; $fn = $ARGV[1]; my $ua = LWP::UserAgent->new(); my %fields = (upload_file => $fn); my $res = $ua->post("http://$URL_Server/cgi-bin/store.pl", \%fields, ' +Content_Type' => 'multipart/form-data'); print $res->as_string;
In reply to LWP file upload question by tcox
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |