>" />

如何在一个 >

发布于 2025-01-14 12:56:43 字数 755 浏览 2 评论 0 原文

这让我很困惑,我想使用带有 multiple 属性的输入来获取一个或多个文件。

我创建了以下表格:

<form method="get">
  <input type="file" name="file" multiple />
  <br /><br />
  <input type="submit" />
</form>

当我选择一个文件并提交表单时,在 URL 末尾和问号 (?) 之后显示:

?file=fileName.jpg

我的问题是,如果用户选择两个文件,它们必须在 URL 中同时显示。如下所示:

?file=fileName.jpg&anotherFileName.jpg

我实际上可以有多个文件。但无论我选择多少个文件,它都只显示一个。

这不是我要找的,它只显示选定的照片(http://jsfiddle.net/0GiS0 /Yvgc2/)。 但我想提交表单中的所有文件,仅使用一个

It's confusing to me, I want to get one or more files using an input with multiple attribute.

I have created the following form:

<form method="get">
  <input type="file" name="file" multiple />
  <br /><br />
  <input type="submit" />
</form>

When I select a file and submit the form, at the end of the URL and after the question mark(?) it shows:

?file=fileName.jpg

My problem is that if the user selects two files, they must show both in the URL. Like the following:

?file=fileName.jpg&anotherFileName.jpg

I can actually have more than one file. But no matter how many files I select, it only shows one.

This is not what I'm looking for, it only shows selected photos (http://jsfiddle.net/0GiS0/Yvgc2/).
But I want to submit all the files in the form, using only one <input type="file" />

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

小兔几 2025-01-21 12:56:43
<form action="/upload" enctype="multipart/form-data" method="post">
  <input type="file" name="file" multiple>
  <br /><br />
  <button>Submit</button>
</form>

使用 post 和 multipart 格式上传文件

<form action="/upload" enctype="multipart/form-data" method="post">
  <input type="file" name="file" multiple>
  <br /><br />
  <button>Submit</button>
</form>

Use post and multipart format to upload files

王权女流氓 2025-01-21 12:56:43
<form method="get" enctype="multipart/form-data">
    <input type="file" name="file" multiple="TRUE" />
    <br /><br />
    <input type="submit" />
  </form>

for 必须添加 multiple = true
输入图片此处描述

<form method="get" enctype="multipart/form-data">
    <input type="file" name="file" multiple="TRUE" />
    <br /><br />
    <input type="submit" />
  </form>

for got to add multiple = true
enter image description here

并安 2025-01-21 12:56:43

输入类型=“文件”名称=“文件”多个=“true”

input type="file" name="file" multiple="true"

折戟 2025-01-21 12:56:43

您可能想看看这些类似的问题:

在名称属性

<input id="image" type="file" name="images[]" multiple="multiple">

链接后面加上括号:

多文件上传器仅发送一个文件

使用该元素的文件属性

var elem = document.getElementById("id_upload");
var names = [];
for (var i = 0; i < elem.files.length; ++ i) {
   names.push(elem.files[i].name);
}

链接:

使用 javascript 从多文件上传控件中检索文件名

You may want to look at these similar problems:

Put brackets after the name attribute

<input id="image" type="file" name="images[]" multiple="multiple">

link:

Multiple file uploader only sends one file

and

Use the files property of that element:

var elem = document.getElementById("id_upload");
var names = [];
for (var i = 0; i < elem.files.length; ++ i) {
   names.push(elem.files[i].name);
}

link:

Retrieving file names out of a multi-file upload control with javascript

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文