Some relevant pieces from an upload script I have. Can't send you the whole thing -- sorry. Read the docs. on the used packages and it should be clear:
use LWP::UserAgent; use HTTP::Request::Common; use HTTP::Headers; my $file = "<something>"; my $ua = LWP::UserAgent->new(); my $request = HTTP::Request->new(); my $response; my $header; my $url = "http://wwww.blahblah/cgi-bin/someuploadscript"; $response = $ua->request(POST $url, Content_Type => 'form-data', Content => [ TextField1 => "TEST", mptest => [$file]]); The key is to use HTTP::Request::Common and to specify a URL that points to an upload CGI on the other end. In your Content, you fill in the form fields. In that content, the form field that takes the file name for uploading is like the one named 'mptest' above. If you need to build a receiving CGI on the other end take a look at the Perl CGI package docs. ---- Steve Sapovits Global Sports Interactive Work Email: [EMAIL PROTECTED] Home Email: [EMAIL PROTECTED] Work Phone: 610-491-7087 Cell: 610-574-7706 Pager: 877-239-4003 > -----Original Message----- > From: Jack Yang [SMTP:[EMAIL PROTECTED]] > Sent: Thursday, December 13, 2001 4:35 PM > To: [EMAIL PROTECTED] > Subject: LWP Upload File > > Hi, there: > > Does anyone know how to upload a file by using LWP commands? > > I have a software which can record all the logfile when I upload a file > to > a website by using IE. Once I have the log file, I then copied the > contents > into the content of the request object, set the content_type to be > "multipart/form-data; boundary=---------------------------7d129e69ec" > which > I copied from the logfile, and used the post method to mimic the upload. > Unfortunately the file could not be uploaded, even I got a 200 returning > code. > > Any suggestion? > > Thanks > > Jack > > > _________________________________________________________ > Do You Yahoo!? > Get your free @yahoo.com address at http://mail.yahoo.com
