我就是想知道前端octobercms怎么上传多个文件没有教程,
我在用
<input name="posting-image" type="file" multiple="multiple" />
Run Code Online (Sandbox Code Playgroud)
然后只得到最后上传的图像
$posting->posting->image=Input::file('posting-image');
$posting->save();
Run Code Online (Sandbox Code Playgroud)
如何检索所有图像?
嘿,如果你想要多个图像,你需要使用 array[] in name of image/file
所以你需要把你的输入写成
<input name="posting-image[]" type="file" multiple="multiple" />
<!-- you need to add this ^ array brackets after name -->
Run Code Online (Sandbox Code Playgroud)
posting-image[] 所以现在这可以容纳多个图像,而不仅仅是最后一个图像。
现在您可以简单地使用它在 php 端获取多个图像
$posting->posting->image= Input::file('posting-image');
// this will return you array of uploaded files
$posting->save();
Run Code Online (Sandbox Code Playgroud)
如果有任何问题,请发表评论。
| 归档时间: |
|
| 查看次数: |
920 次 |
| 最近记录: |