I need to upload a text file to a website on Lunix server.
I run the following Perl script lwpupload without error but the file was not uploaded.
Do I need to pass the file name to the script fileupload.pl which is the url in lwpupload.pl and how ?
Thank you very much for you help.
Mike
PS: Sorry I was unable to post this question, so I'm posting it again.
This script of lwpuload.pl
use CGI;
$cgi=new CGI;
use strict;
use warnings;
use LWP::UserAgent;
use HTTP::Request::Common;
print "Content-type: text/html\n\n";
print "<h1>LWP Upload</h1>";
#
my $ua= LWP::UserAgent->new;
$ua->timeout(30);
my $remotedir="/web/website/docs";
my $URL = 'http://xyz.com/perl/fileupload.pl';
my $req = POST $URL,
Content_Type => 'form-data',
Content=>[
[FILE =>['c:\temp\test2.txt']],
DIR=>"$remotedir",
];
$req->authorization_basic('wwwuser', 'wwwpassword');
my $res = $ua->request($req);
print $res->content;
#
#
This script of fileupload.pl
use CGI;
$cgi=new CGI;
use strict;
use warnings;
print "Content-type: text/html\n\n";
print "<h1>File Upload</h1>";
$remotedir=$cgi->param('DIR');
$upfile=$cgi->param("FILE");
$upload_fh= $cgi->upload("FILE");
exit;