uploading files to an existing cgi script

I'm in stuck by uploading a simple file to a https site, this is what i have:

use LWP::UserAgent;
my $uri = 'https://......../to-users.pl?FILE=%2filest&LANG=en&FUNC=Upload';
my $ua = LWP::UserAgent->new;
$ua->agent("PERL LWP");
my $req = HTTP::Request->new( GET => $uri );
$req->authorization_basic('user', 'pass');
my $res = $ua->request( $req );

if ( $res->is_success ) {
    print $res->as_string;
}

Note: Authentication is not the problem at this point, i'm using this ssl mods from: http://theoryx5.uwinnipeg.ca/ppms/Crypt-SSLeay.ppd

print $res->as_string; shows:
----------------------------------
<form method="POST" action="https://............../to-users.pl" enctype="multipart/form-data">
<input type="hidden" name="DIR" value="/....">
<input type="hidden" name="FUNC" value="UPLOAD2">
<input type="hidden" name="LANG" value="en">
<table border="0">
        <tr>
                <td bgcolor="#CCCCCC"><b>&nbsp;File to upload:&nbsp;</b></td>
                <td><input type="file" name="FILE" size="40"></td>
        </tr>
        <tr>
                <td bgcolor="#CCCCCC"><b>&nbsp;If exists:&nbsp;</b></td>
                <td><input type="checkbox" name="OVR" value="ON"> overwrite</td>
        </tr>
        <tr>
                <td bgcolor="#CCCCCC"><b>&nbsp;Action:&nbsp;</b></td>
                <td><input type="submit" value="Submit"><input type="button" value="Cancel" onclick="location.href='https://.......
/cgi-bin/users/to-users.pl?LANG=en';"></td>
        </tr>
</table>
</form>
----------------------------------

Any help how i could set the submit with the filename and the overwrite chkbox would be appreciatet.

Thx

Matt

LVL 1
MKraussAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rj2Commented:
use HTTP::Request::Common;
use LWP::UserAgent;

$filename='d:/temp/file.txt';
my $ua = LWP::UserAgent->new();
my $response = $ua->request(POST 'https://uid:pwd@www.somewhere.com/cgi-bin/upload.pl',
       Content_Type => 'form-data',
       Content      => [ FILE   => ["$filename"],                  
                       ] );
if ($response->is_success) {
     print "Post ok\n";
} else {
     print "Post failed: ",$response->code,"\n";
}      
0
MKraussAuthor Commented:
thx,
at least i get a Post OK (200) but the file is not uploaded to the correct path, at least i dont
see it in this web file manager, i think i need to set the hidden types "DIR" value="/..... can i do
this somehow ?
0
rj2Commented:
Try like below, set $remotedir to correct value.

use HTTP::Request::Common;
use LWP::UserAgent;

$filename='d:/temp/file.txt';
$remotedir='/usr/home/remotedir';
my $ua = LWP::UserAgent->new();
my $response = $ua->request(POST 'https://uid:pwd@www.somewhere.com/cgi-bin/upload.pl',
       Content_Type => 'form-data',
       Content      => [ FILE   => ["$filename"],                
                       DIR  => "$remotedir",
                       FUNC  => "UPLOAD2",
                       LANG  => "en",
                       ] );
if ($response->is_success) {
     print "Post ok\n";
} else {
     print "Post failed: ",$response->code,"\n";
}    
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MKraussAuthor Commented:
rj2,
after i placed this into productive i noticed a problem with large files,  perl doesnt respond until i abort it
and the files got uploaded fine (?). Is there a way to fix that ?
I can open a new question for this if you want to.
Thanks ....
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.