mike wrote:
I have this:
<form method="PUT" action="work.php">
File: <input type="file" />
<input type="submit" value="Submit" />
</form>
Looking in my webserver logs, it changes that to a GET.
Ideas anyone? The receiver is PHP and I am pretty sure I know how to
handle it once it is properly PUT-ted.
(I run nginx for the server and have enabled PUT as a method, supposedly)
Maybe I need to do something different on the web form though?
I can appreciate why one might imagine otherwise, but XHTML 1.x forms
only support GET and POST. GET and POST are the only allowed values for
the "method" attribute.
If you were validating your markup ( http://validator.w3.org/ ) you'd
have caught that error; if you'd read the HTML documentation for the
FORM element you wouldn't have made it in the first place:
http://www.w3.org/TR/html401/interact/forms.html#h-17.3
There are no conformance criteria in the HTML specification for how user
agents should handle your error; it appears the client you were testing
with submitted the form with the GET method instead.
There are proposals to add PUT and DELETE to the supported methods in a
future version of HTML.
Hard to be sure, but judging from your markup, you might well be using
the wrong HTTP method anyway. The "action" attribute specifies where the
URL the form submits to. In the case of a PUT method, the server is
supposed to replace the resource represented by that URL with the entity
dispatched in the request:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.6
So unless you're intending that, after submission, a GET request to
work.php should return the uploaded file, you're using the wrong method.
I suspect you want the POST method, where the server may do basically
anything with the dispatched entity, such as taking an uploaded file and
making it available at an arbitrary URL (like images/495005.jpg):
http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.5
I note in passing that if you're intending to use that markup in
production, you should really enclose the text "File: " in a "label"
element associated with the "input" element by having a "for" attribute
matching an "id" attribute adding to the "input". This will allow user
agents to accurately associate the label with the file upload control,
for example screen readers and voice browsers can speak or braille
"File: " when the focus enters the control. For a detailed explanation, see:
http://reference.sitepoint.com/html/label
http://www.w3.org/TR/WCAG20-TECHS/H44.html
http://green-beast.com/blog/?p=254
http://www.w3.org/TR/html401/interact/forms.html#h-17.9
Hope that helps.
--
Benjamin Hawkes-Lewis
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php