【问题标题】:Why multiple attribute in input tag of html is not working?为什么 html 的输入标签中的多个属性不起作用?
【发布时间】:2018-11-29 01:56:02
【问题描述】:

我似乎无法让多个标签在我的输入中起作用。我正在尝试拍摄多张照片,这些照片稍后将被纳入健康和安全表格。目前我能做的就是拍一张照片。

我是如何错误地使用它的。我知道它可以与 type="file" 一起使用。我希望这是一个简单的语法错误

<!DOCTYPE html>
<html>
<body>

<h2>The multiple Attributes</h2>
<p>The multiple attribute specifies that the user is allowed to enter more than one value in the input element.</p>

<form action="/action_page.php">
  Take photos: <input type="file" accept="image/*" capture="camera" multiple><br>
  <input type="submit">
</form>

<p>I wonder how I can take more than one photo.</p>

<p><strong>Note:</strong> The multiple attribute of the input tag is not supported in Internet Explorer 9 and earlier versions.</p>

</body>
</html>

【问题讨论】:

标签: php html


【解决方案1】:

需要这样

   <form action="/action_page.php"  method="POST" enctype="multipart/form-data">

 Take photos: <input type="file" name="files[]" type="file" multiple="multiple" accept="image/*" capture="camera" multiple><br>
 <input type="submit">
</form>

【讨论】:

    【解决方案2】:

    您的表单应具有“enctype”属性。并且文件输入你应该有一个属性为“multiple”,这将为你完成工作。

    示例:

        <form action="" enctype="multipart/form-data" method="post">
       <div><label for='upload'>Add Attachments:</label>
       <input id='upload' name="upload[]" type="file" multiple="multiple" />
       </div></form>
    

    但我建议您使用多个文件上传器,例如uploadify。

    【讨论】:

    • 您还需要以相同的形式包含健康和安全事件输入。您可能需要尝试“uploadify”,如果您一次选择多个文件则不会有问题,但如果您选择多次肯定会被覆盖。为了解决这个问题,您可能需要动态生成输入或使用 jquery 文件上传器。希望此评论对您有所帮助。
    【解决方案3】:

    method="POST" enctype="multipart/form-data"

    您错过了不会上传文件和方法的 enctype 应该发布

    enctype(ENCode TYPE) 属性指定表单数据在提交到服务器时应如何编码。 multipart/form-data 是 enctype 属性的值之一,用于有文件上传的表单元素。 multi-part 表示表单数据分成多个部分发送到服务器。

    【讨论】:

      猜你喜欢
      • 2021-11-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-22
      • 2020-01-04
      • 2018-05-05
      • 2018-10-31
      • 2013-08-28
      相关资源
      最近更新 更多