Reputation: 517
I have a Dropzone form to upload files to AWS S3 in Symfony. The action the form calls looks like this.
/**
* @Route("/upload/{inspection}")
* @ParamConverter("inspection", class="AppBundle:Inspection")
*/
public function uploadAction(Request $request, $inspection)
{
$file = $request->files->get('file');
$fileEntity = new File();
$fileEntity->setFileLink($file);
$fileEntity->setInspection($inspection);
$file_link = $this->get('app.entity.inspectionFiles')->handleUpload($fileEntity);
$fileEntity->setFile($file_link);
$inspection->addFile($fileEntity);
$em = $this->getDoctrine()->getManager();
$em->persist($fileEntity);
$em->flush();
return new Response();
}
Now I want to display the already existing files in the Dropzone form. So when someone wants to upload some files, the form shows thumbnails of files that have already been uploaded. The problem is that I have no idea how to do this and I can't find any information on this particular 'construction' anywhere.
Upvotes: 1
Views: 593
Reputation: 186
you should return a JsonResponse with the file url, probably $file_link
In the ajax call that is doing the upload on success you parse the response to get the file_link and show thumbnail with it.
Upvotes: 2