Skip to content

Commit

Permalink
Fix file upload in Symfony v5 (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieudz authored May 2, 2020
1 parent e060e0b commit 580622c
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions Bridges/HttpKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,27 @@ private function mapFiles(&$files)
if (UPLOAD_ERR_OK == $file->getError()) {
file_put_contents($tmpname, (string)$file->getStream());
}
$file = new SymfonyFile(
$tmpname,
$file->getClientFilename(),
$file->getClientMediaType(),
$file->getSize(),
$file->getError(),
true
);
$class = new \ReflectionClass(SymfonyFile::class);
if (count($class->getConstructor()->getParameters()) === 6) {
// Symfony < v4.1
$file = new SymfonyFile(
$tmpname,
$file->getClientFilename(),
$file->getClientMediaType(),
$file->getSize(),
$file->getError(),
true
);
} else {
$file = new SymfonyFile(
$tmpname,
$file->getClientFilename(),
$file->getClientMediaType(),
$file->getError(),
true
);
}

}
}
}
Expand Down

0 comments on commit 580622c

Please sign in to comment.