owenhhs007 has asked for the wisdom of the Perl Monks concerning the following question:

Hi, Monks. I am attempting to upload a file to a page. Original Source html form code is "

<form method="post" action="/cgi-bin/luci/engineer/advanced/diagnostics/upgrade/"></code> " After I login, it changed to

<form method="post" action="/cgi-bin/luci/;stok=4DB4115975EF48FD742227 +BAD3580034/engineer/advanced/diagnostics/upgrade" enctype="multipart/ +form-data"></p> Note: there is a cache generated after login as follows: Set-Cookie: sysauth=ACA415DA69DD4170D34D2DDCE2B610F5; path=/cgi-bin/lu +ci/;stok=44F89C9B8E1EB34F9D379B5162763EAF Location: /cgi-bin/luci/;stok=44F89C9B8E1EB34F9D379B5162763EAF/enginee +r So I need to use the token when doing the upload. The source is follow by "zentaras" <code>#!/usr/bin/perl use warnings; use strict; use LWP::UserAgent; use HTTP::Cookies; use HTTP::Request::Common qw(POST); #test on plain http my $http_post = 'http://192.168.1.1/cgi-bin/luci/engineer/advanced/dia +gnostics/upgrade/'; my $http_user = 'engineer'; my $http_pass = 'ARC$eng&123'; my $file = 'rev1-54.zip'; &postHTTP(); sub postHTTP { my $ua = new LWP::UserAgent; $ua->protocols_allowed( [ 'http'] ); $ua->cookie_jar(HTTP::Cookies->new(file =>".cookies.txt",autos +ave => 1)); #setup request my $req = POST($http_post, Content_Type => 'multipart/form-data', Content =>[ file =>[ $file ], ], ); my $user = 'engineer'; my $pass = 'ARC$eng&123'; $req->authorization_basic($user, $pass); #do post my $response = $ua->request($req); if ($response->is_error()) { printf " %s\n", $response->status_line; print "http request error!\n"; } else { my $content = $response->content(); print "$content\n"; } if ( $response->is_success ) { print $response->as_string; }else { print $response->status_line; } }
The output as follows:

... HTTP/1.0 200 OK Cache-Control: no-cache Vary: Accept Content-Type: text/html; charset=UTF-8 Expires: 0 Client-Date: Thu, 14 Jan 2010 10:27:27 GMT Client-Peer: 192.168.1.1:80 Client-Response-Num: 1 Content-Script-Type: text/javascript Link: </luci-static/ger/cascade.css>; media="screen"; rel="stylesheet"; type="text/css" Title: Test ... <form method="post" action="/cgi-bin/luci/engineer/advanced/diagnostics/upgrade/"> ...

Doesn't doing any uploading. the upload file is a 15M .Zip file. Any wiser can give me the solution? Thanks

Update: I have tried another method please jump to topic:Control IE to upload file issue

Replies are listed 'Best First'.
Re: Post Error (upload files)
by marto (Cardinal) on Jan 14, 2010 at 11:04 UTC
      zentaras and marto, Thanks for your information. I will continue to working on this.
Re: Post Error (upload files)
by apl (Monsignor) on Jan 14, 2010 at 13:57 UTC
    As per martos comments, when you modify a post, you should add a Revised comment, indicating the changes...