【问题标题】:Codeigniter- upload more than one file with only one input fieldCodeigniter - 上传多个文件,只有一个输入字段
【发布时间】:2013-10-18 22:08:52
【问题描述】:

是否有可能使用 codeigniter,甚至根本没有,只有一个输入字段允许用户选择多个文件进行上传。所以基本上你有

<input name="files" type="file">

而不是

<input name="file1" type="file">
<input name="file2" type="file">
<input name="file3" type="file">

我目前知道如何实现后者,但认为前者会是更简洁的模型。

【问题讨论】:

标签: php codeigniter


【解决方案1】:

你有没有调查过PHP manual

<form action="file-upload.php" method="post" enctype="multipart/form-data">
  Send these files:<br />
  <input name="userfile[]" type="file" multiple=""/><br />
  <input type="submit" value="Send files" />
</form>

您在 PHP 中以 $_FILES 的形式访问它

【讨论】:

  • 感谢您的回答。根据文档,我仍然需要多个输入,这并不能真正解决我的问题。
  • 对不起,我忘了一件小事 :) multiple="" 现在试试
【解决方案2】:

您的input 必须是这样的(这样,您可以一次选择多个文件)

<input multiple type="file" name="files[]" />

注意multiple 属性,但并非所有/旧浏览器都支持。

An Example here 也可以看看this tutorial

【讨论】:

  • 只要记住quoted from W3Shools 'Internet Explorer 10、Firefox、Opera、Chrome 和 Safari 都支持 multiple 属性'...如果你想要
  • @gwillie,我认为您没有正确阅读我的答案,我已经提到过。
  • 嗯,我扫描了,但肯定没有接受,显然......我道歉
猜你喜欢
  • 2020-07-25
  • 2012-04-08
  • 1970-01-01
  • 1970-01-01
  • 2014-09-26
  • 1970-01-01
  • 2020-08-21
  • 2019-07-23
  • 1970-01-01
相关资源
最近更新 更多