"1. The data as it comes into the web server is Content-Type: application/octet-stream"

No, it doesn't. You're not looking at the real HTTP headers. A multipart/form-data HTTP message has an uber-header at the top, and then each form field has its own set of mini-headers.

The Content-Type: application/octet-stream header you posted is from the file field's mini-headers. The uber-headers will say Content-Type: multipart/form-data.

A full multipart/form-data HTTP request might look something like this:

POST /handler.cgi HTTP/1.1 Host: http://www.example.com/ Content-Type: multipart/form-data; boundary=XYZ --XYZ Content-Disposition: form-data; name="title" Picture of Camel --XYZ Content-Disposition: form-data; name="upload" Content-Type: image/jpeg ... some binary data ... --XYZ--

The kind of form that might result in that request is:

<form action="http://www.example.com/handler.cgi" method="post" enctype="multipart/form-data"> <fieldset> <legend>Image upload</legend> <label>Image <input name="title"></label><br> <label>File <input name="upload" type="file"></label> <input type="submit"> </fieldset> </form>

And my advice to check the return value of open() still stands.

package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

In reply to Re^3: Problem uploading file data using CGI by tobyink
in thread Problem uploading file data using CGI by dougconran

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.