【问题标题】:Multiple file uploads in octobercmsoctobercms 中的多个文件上传
【发布时间】:2018-04-16 20:44:15
【问题描述】:

我只想知道前端octobercms如何上传多个文件 没有教程,

我正在使用

<input name="posting-image" type="file" multiple="multiple" />

然后只得到最后上传的图片

$posting->posting->image=Input::file('posting-image');
$posting->save();

如何检索所有图像?

【问题讨论】:

    标签: octobercms


    【解决方案1】:

    如果你想要多张图片,你需要使用array[] in name of image/file

    所以你需要把你的输入写成

    <input name="posting-image[]" type="file" multiple="multiple" />
    <!-- you need to add this ^ array brackets after name -->
    

    posting-image[] 所以现在它可以保存多张图片,而不仅仅是最后一张图片。

    现在您可以简单地使用它在 php 端获取多个图像

    $posting->posting->image= Input::file('posting-image');
    // this will return you array of uploaded files
    $posting->save();
    

    如果有什么问题欢迎评论。

    【讨论】:

    • 感谢 Hardik Satasiya
    • 嘿哈迪克,我想知道文件上传字段与数据透视表的可能性,是否可行?我正在尝试,但似乎不起作用。您是 OctoberCMS 核心流程方面的专家。请给我留言。
    • 嗨亲爱的,如果您向我解释什么是架构以及您需要将该文件放在哪里,我可以理解并更好地帮助您:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-29
    • 2016-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-26
    相关资源
    最近更新 更多