douzhouhan4618 2016-06-15 20:15
浏览 60

Symfony $ request-> file-> all()没有所有附件?

I have an angularjs application that adds attachments to a formData and sends it to my symfony controller. To get the uploads and to loop over the multiple uploads from the post, i'm using:

$request->files->all();

and tried:

$request->files;

When i loop over the attachments, symfony is only returning 1 upload? When I check the payload from my Angular app, it shows 2+ files being sent? Shouldn't both of the files be in the Symfony filebag? The API documents show that it should be an array of the files.

Here is a test controller i have been using to try and display the names of the files being uploaded. So far it only shows the last file uploaded.

public function saveAttachment(Request $request) {
    $files = $request->files->all();
    foreach ($files as $file) {
        echo $file->getClientOriginalName();
        echo "<br>";
    }
    exit;
}

I'm not using Symfony forms to generate my HTML, it is separate from the Symfony app.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 DIFY API Endpoint 问题。
    • ¥20 sub地址DHCP问题
    • ¥15 delta降尺度计算的一些细节,有偿
    • ¥15 Arduino红外遥控代码有问题
    • ¥15 数值计算离散正交多项式
    • ¥30 数值计算均差系数编程
    • ¥15 redis-full-check比较 两个集群的数据出错
    • ¥15 Matlab编程问题
    • ¥15 训练的多模态特征融合模型准确度很低怎么办
    • ¥15 kylin启动报错log4j类冲突