Php 如何在symfony 3中以简单的形式上载多个文件
我想创建一个表单,在Symfony 3和简单表单中上载多个文件(图像)(我没有使用Symfony form builder),但我只得到一个文件(第一个文件)。我正在使用POSTMAN通过post方法发送文件Php 如何在symfony 3中以简单的形式上载多个文件,php,forms,symfony,Php,Forms,Symfony,我想创建一个表单,在Symfony 3和简单表单中上载多个文件(图像)(我没有使用Symfony form builder),但我只得到一个文件(第一个文件)。我正在使用POSTMAN通过post方法发送文件 public function testAction(Request $request) { $file = $request->files->get('images'); $ext = $file->guessExtension(); $fil
public function testAction(Request $request)
{
$file = $request->files->get('images');
$ext = $file->guessExtension();
$file_name = time() . '.' . $ext;
$path_of_file = 'uploads/test';
$file->move($path_of_file, $file_name);
var_dump($file);
die();
}
您没有提供足够的信息,但问题可能是您没有在Postman中像这样将key属性设置为array“images[]”-Symfony端点将获得一个UploadedFile对象数组,其中包含有关文件的所有所需数据,您还需要在代码中添加foreach:
public function testAction(Request $request)
{
$file = $request->files->get('images');
foreach ($file as $item) {
do some operations
}
你的表单的html在哪里?我正在使用postman通过post方法发送图像。