Help with file uploads with LWP
Mark Nold (MarkN@awi.com.au)
Wed, 19 Jan 2000 13:31:24 +1100
Hi,
Im using an Activestate Perl (fairly recent) for a script to upload a file =
to a web server.
The recieval script works fine (tested with IE5 as the client), but when i =
use Perl as the client ie get the following prepended to the file;
ntent-Type: text/plain
Then a single newline. When using IE5 as the client it sends the file =
intact with the Content Type header as a POST variable. Basically i would =
like to know how to make my upload work :) I have included the script =
below (which is copied almost from the LWP doco).
If you do have an answer, could you please also CC me direct as im not a =
member of this list.
require LWP;
$file =3D "./somefile.txt";
$filename =3D "somefile.txt";
use HTTP::Request::Common;
$ua =3D LWP::UserAgent->new;
my $req =3D POST 'http://172.16.90.174/test/fileupload2/accept-file.htm',
Content_Type =3D> 'multipart/form-data',
Content =3D> [
var1 =3D> 'Some other post vars',
userfile =3D> [$file,$filename],
];
print $ua->request($req)->as_string;
Mark Nold
markn@alverstone.com.au
Systems Consultant
"Change is inevitable - except from vending machines"