PUT für Updates in Zusammenspiel mit Dateiuploads (curl -XPUT -F file=@path/to/file.png, typ multipart/form-data) funktioniert nicht.
Bei POST parsed PHP den multipart/form-data-Body selbst, bei PUT macht es das nicht.
Keywords:
related:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | <?php class SomeDingoController extends \Illuminate\Routing\Controller { public function update(\Illuminate\Http\Request $request, $id) { $medium = Medium::findOrFail($id); //no, we cannot use $request->getContentType() // because it tries to map to a format $type = $request->headers->get('CONTENT_TYPE'); if (substr($type, 0, 6) == 'image/') { //manually handle PUT file updates $path = tempnam(sys_get_temp_dir(), 'put-fileupload-'); file_put_contents($path, $request->getContent()); $medium->file = new \Illuminate\Http\UploadedFile( $path, 'dummy', $type ); } else { $this->validate(...); $medium->fill($request->all(); } $medium->save(); return $medium; } ?> |