Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > HTTP File Posting

Reply
Thread Tools

HTTP File Posting

 
 
mlm45
Guest
Posts: n/a
 
      04-07-2004
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
 
Reply With Quote
 
 
 
 
Joe Smith
Guest
Posts: n/a
 
      04-07-2004
mlm45 wrote:

> 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
 
Reply With Quote
 
 
 
 
The Dead Bishop
Guest
Posts: n/a
 
      04-08-2004
On Wed, 07 Apr 2004 12:01:26 -0500, mlm45 wrote:

> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HTTP SOAP/HTTP GET/HTTP POST milan_9211 Software 0 01-10-2011 02:10 PM
URL Posting Fails in Medium Trust (3rd time posting this w/ zero replies so far) AmitKu ASP .Net 7 01-08-2007 07:31 PM
CROSS-POSTING, OR MULTI-POSTING, OR NEITHER? Colin D Digital Photography 56 03-08-2006 08:31 PM
Top Posting vs. Bottom Posting scaredkitty Computer Support 37 04-06-2005 12:27 AM
Everytime I hover cursro over a posting, it crosses out with red mark on it.. on every posting alanb ASP .Net 2 04-23-2004 02:23 PM



Advertisments