in reply to How to upload bulk images

Hi, this script will work with plain http (it's shown as https). It shows the basics. You can put the upload in a loop to upload multiple files. For more examples, search groups.google.com for "lwp upload".
#!/usr/bin/perl use warnings; use strict; use LWP::UserAgent; use HTTP::Cookies; use HTTP::Request::Common qw(POST); my $https_url = 'https://zentara.zentara.net/~zentara/cgi-bin/uploads/ +up1.cgi'; my $https_user = 'zentara'; my $https_pass = 'foobar'; my $file = 'testout.tgz'; &postHTTPS(); sub postHTTPS { my $ua = new LWP::UserAgent; $ua->protocols_allowed( [ 'https'] ); $ua->cookie_jar(HTTP::Cookies->new(file =>".cookies.txt",autos +ave => 1)); #setup request my $req = POST($https_url, Content_Type => 'multipart/form-data', Content =>[ file =>[ $file ], ], ); #setup auth $req->authorization_basic($https_user, $https_pass); #do post my $response = $ua->request($req); if ($response->is_error()) { printf " %s\n", $response->status_line; print "https request error!\n"; } else { my $content = $response->content(); print "$content\n"; } if ( $response->is_success ) { print $response->as_string; }else { print $response->status_line; } }

I'm not really a human, but I play one on earth. Cogito ergo sum a bum

Replies are listed 'Best First'.
Re^2: How to upload bulk images
by Anonymous Monk on Jan 03, 2008 at 09:18 UTC
    Thank you all. The server is Windows (DB is MS-SQL Server, which I will connect using DBI).
      If possible I would like to reduce the image size, that is why I had mentioned image-magick. But if it can be done using plain PERL, GREAT. Thanks
        I would not recommend using Image::Magick modules and instead just directly using the command line magick tools (eg. convert). We have had difficulty compiling perlmagick and once installed segfaults on some servers. I have found just wrapping convert with the proper parameters a bit more stable and, interestingly, faster.