HTTP File Posting

Discussion in 'Perl' started by mlm45, Apr 7, 2004.

  1. mlm45

    mlm45 Guest

    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
    mlm45, Apr 7, 2004
    #1
    1. Advertising

  2. mlm45

    Joe Smith Guest

    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
    Joe Smith, Apr 7, 2004
    #2
    1. Advertising

  3. 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
    The Dead Bishop, Apr 8, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. alanb
    Replies:
    2
    Views:
    519
    alanb
    Apr 23, 2004
  2. Martin Feuersteiner

    Posting Text containing '&' Symbol via HTTP

    Martin Feuersteiner, Apr 28, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    349
    Martin Feuersteiner
    Apr 28, 2004
  3. ppcdev
    Replies:
    0
    Views:
    486
    ppcdev
    Jan 13, 2004
  4. Java Job
    Replies:
    0
    Views:
    410
    Java Job
    Jul 21, 2004
  5. AmitKu
    Replies:
    7
    Views:
    499
    John Timney \(MVP\)
    Jan 8, 2007
Loading...

Share This Page