Hi, monks, I have a question about upload a big file.
use Win32::IE::Mechanize; my $url = 'http://192.168.1.1/cgi-bin/luci/engineer/advanced/diagn +ostics/upgrade'; #my $username = 'engineer'; #my $password = 'ARC$eng&123'; my $file = 'C:\Documents and Settings\michaelhuang\Desktop\rev1-54 +.zip'; my $ie = Win32::IE::Mechanize->new( visible => 1); $ie->get( $url); $ie->form_number(4); $ie->set_fields( username => 'engineer', password => 'ARC$eng&123' ); $ie->submit(); $ie->form_number(4); $ie->set_fields( #filename=>'rev1-54.zip' image => $file, ); $ie->submit();
output from IE is :The file uploaded may be of the wrong type or damaged. My question is

1.Why I can't submit this form to implement the upload?

2.I wanna use this script to control the IE to do the upload, need I need other model except Win32::IE::Mechanize?

3.In the Win32::IE::Mechanize source code, how to set up the argument of $mech->value( $name, $number ), does this method can help my script?

4.If I use other way to do the upload, I need to find the new URL for upload, which way is the easiest way to find the URL?(It can redirect to the new URL after I manually login, but failed to find using this script)

I am a newbie of Perl, I will appreciate for anyone give thread to me.

Update: I have found the issue is in trace back in source of webpage. The type of input is "file", so I can't use submit_form with text inside.


In reply to Control IE to upload file issue by owenhhs007

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.