in reply to Re^2: Problem uploading file data using CGI
in thread Problem uploading file data using CGI
"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.
|
|---|