On Wed, 16 Mar 2011, Peter J. Holzer wrote:
It's not just different headers. A multipart/form-data must be a valid
multipart MIME message with appropriate separators, headers for each
part, etc. It isn't very complex (and IMHO support for it should be
included in any HTTP client library since it's one of two common forms
for POST requests), but there are some caveats (for example, you must
make sure that the separator doesn't occur in the file you try to
upload).
Yes, when I use curl on OSX it gets it right, and the server matches it,
and the file gets written with writefile, but only because it's tied to a
parameter, like this:
curl --form [email protected] --form press=OK
'http://www.server.se/json/1.0/userUploadTapPic.json?apikey=3556'
{
"api_version": "1.0",
"api_key": "3556",
"generated": "2011-03-16T12:57:15",
"headers": {
"expect": "100-continue", "content-length": "136453", "host":
"www.server.se", "accept": "*/*", "content-type": "multipart/form-data;
boundary=----------------------------a0b84568a94e", "user-agent":
"curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l
zlib/1.2.3"
}
"status": "ok"
}
If you just send a file as the body of a POST request, it's much
simpler. But browsers never do this, so server-side support may be
lacking (the Perl CGI module supports it: To the user of the module it
looks as if there was a single parameter named "POST_DATA").
That's true, I recognize this and I even think I've used it some time in
the past...
/Rolf