I've been using a WWW::Mechanize script for a couple years to automate some maintenance activities for one of our products (Lyris ListManager, if anyone happens to be familiar). After upgrading the app to a newer version, my script stopped working, though it's not actually "failing" as far as the script is concerned - it's just not doing what it's intended to do. I've been doing tcpdumps and such, and the only notable difference I can find is that the file I'm uploading via the web form has a different content-type via Mechanize vs a browser. Is there a way I can specify a file type for a "file" form field? I don't know if it really matters, as the data being sent is identical in both traces, but it's all I can come up with so far. I'm far from a Mechanize expert, and I'm struggling to troubleshoot further.

The submit button is a linked image, and I'm using click() to call it, specifying the name and some coordinates I stole from a tcpdump from a web session. I didn't have to use coordinates previously, so I'm not entirely sure if I can just pick coords like that, or if they are dynamic and relative to the session somehow.

Below are snippets of the POST, indicating the only notable differences I could find.

Anyone have any ideas? I can post the entire POST if needed...

Working:

-----------------------------2995119424827 Content-Disposition: form-data; name="file_name"; filename="test.csv" Content-Type: application/vnd.ms-excel <data here> -----------------------------2995119424827 Content-Disposition: form-data; name="import.x" 22 -----------------------------2995119424827 Content-Disposition: form-data; name="import.y" 3 -----------------------------2995119424827--

Not Working:

--xYzZY Content-Disposition: form-data; name="file_name"; filename="<path>/tes +t.csv" Content-Type: text/plain <data here> --xYzZY Content-Disposition: form-data; name="import.x" 20 --xYzZY Content-Disposition: form-data; name="import.y" 9 --xYzZY--

In reply to WWW::Mechanize issue by shag

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.