rest - How to send form data in slim framework v3 in PUT routing -


i new in slim framework , using slim v3 have done post route , works fine when try update record put method works content-type = application/x-www-form-urlencoded , update record success

enter image description here

when try send file slim api postman chrome extension not sending file form data request.

enter image description here

here code

$app->put('/message/{message_id}', function ($request, $response, $args) {     $imagepath = '';      $data = $request->getparsedbody();      $files = $request->getuploadedfiles();      $file = $files['file'];     if ($file->geterror() == upload_err_ok ) {         $filename = $file->getclientfilename();         $file->moveto('assets/images/'.$filename);         $imagepath = 'assets/images/'.$filename;     }      $message = message::find($args['message_id']);     $message->body = $data['message'];     $message->user_id = $data['user_id'];     $message->image_url = $imagepath;     $message->save();      if ($message->id) {         return $response->withstatus(200)->withjson([                 'message_id' => $message->id,                 'message_uri' => '/message/'.$message->id,             ]);     }else{         return $response->withstatus(400)->withjson(['message'=>'something went wrong!']);     }  }); 

when want upload file postman need remove or disable content-type inside header.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -