Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: LWP and POST (Oh no, not again)

by gildir (Pilgrim)
on Dec 13, 2001 at 19:32 UTC ( [id://131633]=note: print w/replies, xml ) Need Help??


in reply to LWP and POST (Oh no, not again)

Try it this way:

use LWP; my $ua = LWP::UserAgent->new; my $req = HTTP::Request->new( POST => $url); $req->content_type('image/jpeg'); open(FILE,$filename); $req->content(join('',<FILE>)); close(FILE); my $res = $ua->request($req); die("Bzzzzzzz, error!") unless $res->is_success;
You must set proper content type. And I just can't figure out why are you trying to base64 encode the file. Without the headers is base64 encoding pointless.

If server does not support direct upload of picture this way, you should probably encode it as a part of HTML form. Use content type of 'multipart/form-data' and you should probably use some (MIME?) modules to build up a content with proper headers.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://131633]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-20 01:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found