Search code examples
phpfile-uploadhttp-put

PHP upload file using PUT instead of POST


I read something about this on PHP docs, but it's not clear to me:

  1. Do the most widely used browsers (IE, FF, Chrome, Safari, Opera, ...) support this PUT method to upload files?

  2. What HTML should I write to make the browser call the server via a PUT request? I mean do I need to write a FORM with an INPUT file field and just replace the attribute method="POST"with method="PUT"?

  3. On the PHP docs (link above) they say a PUT request is much simpler than a POST request when uploading file, along with this advantage, what other advantages/disadvanatges do the PUT has got compared to the POST?


Solution

  • I think the method is supported by most major browsers, but you can't account for every browser and other client that is out there. From a cursory look at the user contributed notes, this sometimes even needs server-side configuration to work.

    Also, handling any additional form values you may want to send along with your file becomes more difficult.

    I wouldn't use it. Way too much possible hassle for little actual gain.