Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If I try to to submit form data using "Content-Type: multipart/form-data", the request is rejected with the message "406 Not Acceptable: Unsupported request content type multipart/form-data". Multipart forms should be supported because they are the best way to upload images.
Comments
Comment #1
marcingy CreditAttribution: marcingy commentedThis is a duplicate of #1066154: Add support for multipart/form file upload which I believe needs some d6 testers.
Comment #2
marcingy CreditAttribution: marcingy commentedmeh
Comment #3
voxpelli CreditAttribution: voxpelli commentedThe solution in #1066154: Add support for multipart/form file upload was never supposed to work with PUT requests - only with POST requests since PHP doesn't recognize PUT requests and therefor doesn't know how to handle them. That's one of the reasons why I thought we should either code our own support for multipart or not support it at all.
Marking this as active since #1066154: Add support for multipart/form file upload won't solve it.
Regarding multipart being the best way to upload images - I disagree. A PUT or POST containing the raw file alone would in my opinion be better since it's easier and as far as I know there's also support for building such resources in Services already.
Comment #4
jnross CreditAttribution: jnross commentedvoxpelli,
You're right that uploading a raw file alone is a great solution - this is the strategy I'm currently working on. My statement in the original report would be better put as: Multipart forms are a better way to send a raw file and metadata than a JSON or XML request with base64_encode, because it avoids the encoding overhead and inflation.
Comment #5
kylebrowning CreditAttribution: kylebrowning commentedIts been fixed in 7.x by adding it to the parsers for the rest server, however this wasn't done in 6.x
'multipart/form-data' => 'RESTServer::parseFile',
This has been fixed in 6.x
Comment #6
kylebrowning CreditAttribution: kylebrowning commentedComment #8
lasconic CreditAttribution: lasconic commentedAs a reference, here is the related PHP bug : https://bugs.php.net/bug.php?id=55815
"PUT request data should be parsed just like POST"
Comment #9
jwilson3multipart/form-data in PUT requests will finally be parsed and handled properly in PHP 8.4
https://wiki.php.net/rfc/rfc1867-non-post