From: "Dermot" <paik...@googlemail.com>
2009/8/2 Octavian Râşniţă <orasn...@gmail.com>:
From: "Shawn H. Corey" <shawnhco...@gmail.com>

Octavian Râşniţă wrote:

Hi,

Due to the file size limitations of the common browsers like IE or
Firefox, I wanted to create a file uploader that doesn't use a browser, but
just posts a file to a program on a server.

I might have the wrong end of the stick here but couldn't you use LWP for this?
Dp.

Oh yes I can, but it seems that I am missing something and the uploader doesn't work.

I have tried:

use strict;
use LWP::UserAgent;

my $ua = LWP::UserAgent->new;

#The boundary:
my $hash = "------xx9859x" . time();

my $req = HTTP::Request->new(POST => 'http://www.site.com/upload');
$req->content_type("multipart/form-data; boundary=$hash");

my $file_content = <<EOF;
$hash
Content-Disposition: form-data; name="file"; filename="E:\\filename.txt"
Content-Type: text/plain

The body of the text file
$hash
EOF

$req->content($file_content);

my $res = $ua->request($req);

__END__

The html form that uploads the files has an action of "/upload" and the field name of the "file" field is "file".

But nothing is uploaded.

Thanks.

Octavian


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to