Upload a PHP file using PUT instead of POST

I read about it in PHP docs , but this is not clear to me:

  • Do the most common browsers (IE, FF, Chrome, Safari, Opera, ...) support this PUT method for downloading files?

  • What HTML should I write for the browser to call the server through a PUT request? I want to say that I need to write FORM with the INPUT file field and just replace the method="POST" attribute with method="PUT" ?

  • In the PHP docs (link above) they say that a PUT request is much simpler than a POST request when downloading a file along with this advantage, what other advantages / disadvantages do PUT have compared to POST ?

+6
php file-upload
source share
4 answers

I think that the method is supported by most major browsers, but you cannot take into account each browser and the other client that is located there. From a quick look at user notes, this sometimes even requires a server configuration to work.

In addition, processing any additional forms that you want to submit with your file becomes more complex.

I would not use it. The way is too much trouble for a small actual gain.

+1
source share

The PUT method cannot be used from form <. MSIE does not support it through a graphical user interface. However, you can use XMLHttpRequest . It seems to be defined in the standard and WHATWG / HTML5. He clearly likes my browser (Opera).

http://old.mnot.net/javascript/xmlhttprequest/ IE may also work as a short Google search suggests. And Firefox looks great. Not verified by Chrome or Webkit.

On the server, you will need a specially assigned script to process the incoming PUT request. Take a look at the Apache docs. Usually the mod_rewrite rule. The main advantage of PUT is the lack of encoding / sorting of files in the required multipart / * mime type. Theoretically, this allows you to more reliably download larger files. If you use PHP, this will not help you. It is designed for web servers with WebDAV support and / or direct access to the file system. (Apache can save downloaded files on its own if you use this.)

+6
source share

PUT not very widely supported by browsers and is not commonly used for interactive HTML forms.

0
source share

The fact that PUT rarely used for this purpose and is only supported by major browsers excludes it from any possible use here.

0
source share

All Articles