4

I'm in the midst of writing a RESTful API, but sadly PHP doesn't have much built-in support for the PUT method.

Does anyone know of a script/library that would parse multipart/form-data in PHP?

Obto
  • 1,377
  • 1
  • 20
  • 33
  • If you've [set up PUT handling](http://php.net/manual/en/features.file-upload.put-method.php) correctly, [here's a hack](http://stackoverflow.com/a/5488449/1122351). – benesch Mar 20 '12 at 03:18
  • Doesn't look like that solution will work with requests containing binary data, as I don't think preg_match is binary safe. I can try it out later tonight, though – Obto Mar 20 '12 at 03:36
  • PCRE functions *should* be binary safe. – benesch Mar 20 '12 at 11:02
  • Well it looks like I'll have to write my own, as that hack reads the whole input into memory which isn't a good idea if people are uploading huge files heh. I'll comment back if/when I finish the parser. – Obto Mar 20 '12 at 16:28

1 Answers1

-4

You can use parse_str(file_get_contents("php://input"), $vars) to access PUT data

Philip
  • 4,592
  • 2
  • 20
  • 28