After being forced to do some unplanned research, I realise that uploading a file using PUT is not so straightforward as I expected. As far as I understand, this is more due to PHP $_FILES only recognising POST, rather than anything do do with the PUT method itself, but that doesn't help me much!
As far as I can see, the FuelPHP Upload class appears to depend on $_FILES, and hence doesn't play with PUT.
Is there any way the FuelPHP Upload class will work with PUT? If so, is there some documentation you can point me to?
Otherwise, is there any kludge I can do to upload a file using PUT, or will I just have to distort the API by using POST for what should strictly be PUT/PATCH?
No, there isn't. Also, the current Input class doesn't support multipart input on PUT/PATCH, so it won't be able to get the file binary out.
My 2ct's on why this hasn't been implemented in PHP is that from a HTTP spec point of view, PUT was designed as the opposite of GET, with a monolitic payload send to a URL (in "put this there"). It was never designed as the opposite of POST, and it isn't parsed as such.
The Input class has currently been designed to work around this for www-form-urlencoded data (equivalent to a form post), but not for multipart/form-data. Doing this properly would also require internal access to PHP's $_FILES structure, because even if you could populate this from PHP code in a PUT request, PHP will not recognize it as valid (i.e. move_uploaded_file() and friends won't work),
Parsing the multipart section shouldn't be to difficult, problem is to make PHP believe it was an uploaded file.
For security reasons, you can not populate $_FILES manually (well, you can, but PHP wiil not see it as an uploaded file) from PHP code, as documented in the PHP manual.
The only correct solution would be to have PHP parse PUT, PATCH and DELETE the same way it does POST, which as far as I know isn't even on the roadmap, see the dev teams response: https://bugs.php.net/bug.php?id=55815