in reply to Re: Help required regarding HTTP::Request::Common, File upload
in thread Help required regarding HTTP::Request::Common, File upload

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on Re^2: Help required regarding HTTP::Request::Common, File upload

Replies are listed 'Best First'.
Re^3: Help required regarding HTTP::Request::Common, File upload
by Corion (Patriarch) on Apr 29, 2008 at 09:32 UTC
      Thanks Mate! I re-wrote everything using WWW::Mechanize and its working now! Change i had done is, instead of having calling the URL, i wrote a HTML page, with the necessary parameters and hosted in a webserver and accessing it via WWW::Mechanize
      MY code
      use WWW::Mechanize; use HTTP::Cookies; my $user = 'userid'; my $pass = 'password'; my $login_url = 'https://myserver.com/login'; my $upload_url = "http://mylocalserver/File_Upload.html"; my $file = "C:\\ExportFile.csv"; $ENV{HTTPS_PROXY} = 'http://proxyserver' $ENV{HTTPS_PROXY_USERNAME} = 'user'; $ENV{HTTPS_PROXY_PASSWORD} = 'pwd'; $ENV{HTTP_PROXY} = 'http://proxyserver'; $ENV{HTTP_PROXY_USERNAME} = 'usre'; $ENV{HTTP_PROXY_PASSWORD} = 'pwd'; my $cookie_jar = HTTP::Cookies->new(file => 'cookies.txt',autosave => +1); my $mech = WWW::Mechanize->new( autocheck => 1 ); $mech->proxy(https => undef); $mech->proxy(http => undef); $mech->credentials( $user => $pass ); $mech->get( $login_url ); my $response = $mech->response(); $cookie_jar->extract_cookies($response); $cookie_jar->save(); #added new $mech->cookie_jar($cookie_jar); $mech->get($upload_url); $mech->form_number(1); $mech->set_fields(theFile => $file); #'thefile' id control name in the + HTML page $mech->submit(); die unless ($mech->success);

      Is it possible to have this HTML page in local machine ex: C:\fileupload.html and access it via WWW::Mechanize? i get protocol error

      Thanks for your tips
      Cheers
      Karthik

        Yes - you can load a local file into WWW::Mechanize by using the file:// protocol instead of using http://.