tcox has asked for the wisdom of the Perl Monks concerning the following question:
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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: LWP file upload question
by davorg (Chancellor) on Aug 18, 2004 at 13:59 UTC | |
|
Re: LWP file upload question
by iburrell (Chaplain) on Aug 18, 2004 at 16:15 UTC | |
|
Re: LWP file upload question
by reneeb (Chaplain) on Aug 18, 2004 at 17:08 UTC | |
|
Re: LWP file upload question
by Plankton (Vicar) on Aug 18, 2004 at 14:18 UTC | |
by tcox (Novice) on Aug 18, 2004 at 14:36 UTC | |
|
Re: LWP file upload question
by Plankton (Vicar) on Aug 18, 2004 at 15:00 UTC |