I thought that there would be no problem integrating LWP on the client side and CGI on the server side but this does not seem to be the case.
I am using a call like this on the client:
my $enctype = 'form-data/multipart'; $ua = LWP::UserAgent->new; $req = POST $url, Content_Type => $enctype, Content => [ p_progra_idint =>$p_progra_idint, p_upload => [$path_file,$name_file] ]; $res = $ua->request($req);
And on the server side:
Strangely, if I use 'form-data/multipart' all variables except the file are read perfectly on the server side, on the other hand if I use 'multipart/form-data' (which is what it should be) all sorts of erroneous variables are read.$CGI::DISABLE_UPLOADS = 0; $ENV{'TMPDIR'} = $tpath; binmode(STDIN); $req = new CGI(\*STDIN); my $fh = $req->upload('p_upload'); my $buffer; open (OUTFILE, ">$path_sortida") or die "Unable to create upload output file $! \n"; binmode $fh; binmode OUTFILE; my ($bytes, $read); $bytes = 0; while ($read = read ($fh, $buffer, 16384)) { print OUTFILE $buffer; $bytes += $read; } close OUTFILE;
With the first option as encoding, all vars are read, but 0 bytes of the file are returned after the bucle. The file is created but with zero size.
I have browsed the perlmonks archives and tutorials as well as done some obvious google querys, now I am lost and I am thinking on doing the parsing by hand on the server (ugh).
Thanks in advance.
In reply to Yet another file-upload question (using LPW--->CGI) by dani++
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |