开发者

Can enctype="multipart/form-data" be used for non file inputs as well?

开发者 https://www.devze.com 2023-04-09 13:18 出处:网络
Is this allowed? <form enctype=\"multipart/form-data\" action=\"__URL__\" method=\"POST\"> <input type=\"text\" name=\"text_input\" />

Is this allowed?

<form enctype="multipart/form-data" action="__URL__" method="POST">
  <input type="text" name="text_input" />
  <input type="other_types" name="other_types_input" />
  <input t开发者_Python百科ype="hidden" name="MAX_FILE_SIZE" value="30000" />
  <input name="userfile" type="file" />
  <input type="submit" value="Submit" />
</form>

It will be used with PHP...


Yes, it's absolutely correct. No issues.


This is perfectly fine.

It's how forms with file elements in them are normally structured.


Though the question is old, the answers already posted has no explanation, so I am adding this, so that it will be helpful for future readers.

The HTTP POST method sends data to the server. The type of the body of the request is indicated by the Content-Type header. The content type is selected by putting the adequate string in the enctype attribute of the element or the formenctype attribute of the or elements. HTML forms provide three methods of encoding.

  1. application/x-www-form-urlencoded (the default)
  2. multipart/form-data
  3. text/plain

for multipart/form-data, each value is sent as a block of data ("body part"), with a user agent-defined delimiter ("boundary") separating each part. The keys are given in the Content-Disposition header of each part. It does not matter if you are sending file or not. so it should be fine.

Refer mozila doc

0

精彩评论

暂无评论...
验证码 换一张
取 消