代码之家  ›  专栏  ›  技术社区  ›  Amjad Niazi

10月CMS中的多个文件上载

  •  2
  • Amjad Niazi  · 技术社区  · 7 年前

    我只是想知道如何在10月CMS的前端上传多个文件 没有教程,

    我正在使用

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

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

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

    如何检索所有图像?

    1 回复  |  直到 7 年前
        1
  •  5
  •   Hardik Satasiya    7 年前

    嘿,如果你想要多个你需要使用的图像 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();
    

    如果有任何问题,请评论。