HTML文件上传类型=“文件”也从type =“text”输入字段上传

时间:2014-12-23 21:13:57

标签: html image file upload

这是我的HTML代码。在浏览器中,我单击文本字段,并显示一个文件输入框。这就像我选择了type =" file"输入字段。为什么我的HTML代码会这样做?

<div id = "section">
<form action = "receive.php" method = "post">
<!-- Image to upload -->
    <label for = "item"> Item: <input id = "item" type = "file" name = "items" accept = "image/*">
<!-- Text to enter -->
    <label for = "mail"> Email: <input id = "mail" type = "text" name = "email">
    <label for = "word"> Words: <input id = "word" type = "text" name = "words">
    <input type = "submit" value = "Submit" name = "submit">
</form>
</div>

2 个答案:

答案 0 :(得分:2)

您需要关闭<label>代码。

否则,您的整个表单都在<label>的上传控件中,点击该标签会点击该控件。

答案 1 :(得分:0)

您尚未正确关闭元素,很可能是<label>元素。

&#13;
&#13;
<div id = "section">
<form action = "receive.php" method = "post">
<!-- Image to upload -->
    <label for = "item"> Item: <input id = "item" type = "file" name = "items" accept = "image/*"></label>
<!-- Text to enter -->
    <label for = "mail"> Email: <input id = "mail" type = "text" name = "email"></label>
    <label for = "word"> Words: <input id = "word" type = "text" name = "words"></label>
    <input type = "submit" value = "Submit" name = "submit">
</form>
</div>
&#13;
&#13;
&#13;