In this article, we will learn how to allow multiple files uploads in HTML forms.
我们使用多个属性,以允许在HTML表单中进行多个文件上传。多个属性适用于电子邮件和文件输入类型。
If you want to allow a user to upload the file to your website, you need to use a file upload box, also known as a file, select box. This is created using the element and the type of attribute is set to file.
以下是在HTML表单中选择多个文件上传的语法。
<input type="file" name="name" multiple>
以下是HTML表单中选择多个文件上传的示例程序。
<!DOCTYPE html> <html> <head> <title>Upload multiple files</title> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <form> <input type="file" name="name" multiple><br><br> <br> <input type="submit" value="Submit"> </form> </body> </html>
以下是上述示例程序的输出,其中在输入字段中未选择任何文件。
We have chosen only one file in the input field. Below is the output shows the file, we have chosen.
我们也可以选择尽可能多的文件。下面的输出显示我们选择的文件数量。
The below syntax work same as the above-mentioned syntax. We assign ‘multiple’ attribute with the value of multiple for selecting multiple files in the input field.
以下是在HTML表单中选择多个文件上传的语法。
<input type="file" name="name" multiple=>
以下是在HTML表单中选择多个文件上传的示例程序。
<!DOCTYPE html> <html> <head> <title>Upload multiple files</title> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <form> <input type="file" name="name" multiple="multiple"><br><br> <br> <input type="submit" value="Submit"> </form> </body> </html>
正如我们在输出中看到的,我们已经选择了四个文件进行上传。
以上是如何在HTML表单中允许多个文件上传的详细内容。更多信息请关注PHP中文网其他相关文章!