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

!/usr/bin/perl

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);

if ($res->is_success)

print $res->content;

else
print "Post failed: ",$res->code,"\n";

#

#

This script of fileupload.pl

!/usr/bin/perl

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");

pprint "<P>remotedir=$remotedir"; # it displays correctly
print "<P>upfile=$upfile"; # upfile is blank
print "<P>upload_fh=$upload_fh"; # upload_fh is blank

exit;

Sorry... I have tried to use WWW::Mechanize and still could not make it work. I I wonder if you could show me the basic script that I can base on to continue to work on what I need.
Thank you.
Mike

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.