HTTP File Posting

M

mlm45

I am hoping to find a way to post a file to a remote web page in an
automatic way using a perl script on a Windows machine. I prefer not to
use FTP as I have to put passwords in the script. I'd also like to avoid
SMTP.

Is there a way to have a perl program send a local file to a remote
computer using http?


Thanks
Mark
 
J

Joe Smith

mlm45 said:
Is there a way to have a perl program send a local file to a remote
computer using http?

Yes, provided that the remote computer is set up for file uploads.

There has to be a CGI on the remote web server explictly designed
to accept HTTP POST of file data. Check out LWP, lwp-cookbook, and
HTTP::Request::Common. Docs for the latter mention Form-Based File Upload.
-Joe
 
T

The Dead Bishop

I am hoping to find a way to post a file to a remote web page in an
automatic way using a perl script on a Windows machine. I prefer not to
use FTP as I have to put passwords in the script. I'd also like to avoid
SMTP.

Is there a way to have a perl program send a local file to a remote
computer using http?


Thanks
Mark

I recently wrote something like that. Unfotunately, I use FTP.
Try something like this:


#!/usr/bin/perl -w

use Net::FTP;
use Cwd;

$Host = "ftp.whatever.com" ;
$User = "loginname" ;
$Pwrd = "password" ;
$Dir = "/www" ; # i.e. the target dir on the remote server

print "<p>\n\nConnecting to $Host " ;
$ftp = Net::FTP->new($Host, Debug => 0)
|| die "Cannot connect to '$Host' : '$@' " ;

print "<br>Logging in user '$User', and password ... " ;
$ftp -> login ($User, $Pwrd)
|| die "Cannot login ", $ftp->message ;

print " cwd to '$Dir', " ;
$ftp -> cwd ($Dir)
|| die "Cannot change dir to '$Dir'" ;

print "<br>Writing files : " ;
foreach $File (@FileList) {
$ftp -> put ($File)
|| die "Cannot put file ", $ftp->message ;
}

print "<br>Done. Logging out. " ;
$ftp -> quit ;



hth,

Arno Reuser
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top