| Conditions | 2 |
| Paths | 2 |
| Total Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 29 | public function postImageAction(Request $request) |
||
| 30 | { |
||
| 31 | if (!$request->files->has('file')) { |
||
| 32 | throw new BadRequestHttpException('Aucun fichier fourni'); |
||
| 33 | } |
||
| 34 | |||
| 35 | $image = new Image(); |
||
| 36 | $file = $request->files->get('file'); |
||
| 37 | $image->setExt($file->guessExtension()); |
||
| 38 | $image->setFile($file); |
||
| 39 | |||
| 40 | $manager = $this->getDoctrine()->getManager(); |
||
| 41 | $manager->persist($image); |
||
| 42 | $manager->flush(); |
||
| 43 | |||
| 44 | return $this->json([ |
||
| 45 | 'filelink' => '../api/'.$image->getWebPath(), |
||
| 46 | ], 201); |
||
| 47 | } |
||
| 48 | } |
||
| 49 |