Sunday, November 28, 2010

What is the use of enctype attribute in HTML form?

ENCTYPE is an attribute in HTML form which is used whenever we have to upload file(s). But have we ever thought about what this attribute do? Why do we not receive any file information on server if this attribute is not used in the form?
The default value of enctype attribute is "application/x-www-form-urlencoded". But, in case of file upload you should use "multipart/form-data".
ENCTYPE determines how the form data is encoded. Whenever data is transmitted from one place to another, there needs to be an agreed upon means of representing that data. ENCTYPE separates the uploaded data into text and binary. Only then uploaded file information will be accessed on server side via $_FILE['filecontrolname']. Other field of form will be accessed via $_REQUEST['controlname'] or $_GET['controlname'] or $_POST['controlname'].

No comments:

Post a Comment

Thanks for your valuable comments.

Important queries based formulas to watch performance of a MySQL based application

(1) Session Vs global status variables value select G.variable_name,G.variable_value GlobalValue,S.variable_value SessionValue from (selec...