{
"code": 0,
"count": 2,
"amount": "1750.00",
"items": [
{
"id": 1,
"order_sn": "5EE7260B",
"status": "new",
"count": 1,
"amount": "1650.00",
"create_at": "2019-10-06T10:13:55+00:00"
},
{
"id": 2,
"order_sn": "5EE7260С",
"status": "new",
"count": 1,
"amount": "100.00",
"create_at": "2019-10-06T10:13:55+00:00"
}
]
}
public function fileUpload(Request $request)
{
/** @var File $file */
$file = $request->files->get('file');
$originalFilename = pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME);
$safeFilename = transliterator_transliterate('Any-Latin; Latin-ASCII; [^A-Za-z0-9_] remove; Lower()', $originalFilename);
$fileName = $safeFilename.'-'.uniqid().'.'.$file->guessExtension();
try {
$file->move($this->images, $fileName);
} catch (FileException $e) {
// ... handle exception if something happens during file upload
}
//print_r([$originalFilename, $fileName, $safeFilename, $this->images]); exit;
$fullname = sprintf("%s/%s", $this->images, $fileName);
return new JsonResponse([
"code" => 0,
"path" => $fullname
]);
}
htop
Так же как и без симфони: получить из реквеста файл и сохранить. Или я что-то не понял в вопросе?