Open ItzfeminisceBEnd opened 1 year ago
Hey,
can you share your request body and headers with us?
~ Marius
Request Header: Authorization: Bearer <token> User-Agent: PostmanRuntime/7.34.0 Accept: / Cache-Control: no-cache Postman-Token: 5c0fe45e-0db4-44dd-b83b-0250c95fe87f Host: localhost Accept-Encoding: gzip, deflate, br Connection: keep-alive Content-Type: multipart/form-data; boundary=--------------------------191050165857157560352247 Cookie: PHPSESSID=hhgbb05m0eklch792b435rjutt Content-Length: 19554622
Request Body: post_text: "Hello world" post_img: <file>
MY CODE:
public function store() {
try {
$validate = purify(input()->all());
$req = $validate([
"post_text" => 'required',
"post_img" => 'optional',
]);
//input()->file('post_img') // Always null
// $req->post_text == input()->find("post_text)
// $req->post_img == input()->file(post-img) // Butt this is always null
return Post::getInstance()->store($req->post_text, input()->file("post_img", null));
}catch(\Exception $e) {
Logger::system($e->getMessage());
return json_response(["message" => $e->getMessage()]);
}
}
The input()->() and request()-> will not catch file contents in request.
I have tried every possible means to handle uploaded files but it's not present in the request body.
I set content type to application/json, it won't. I also set it to url-encoded, even form-data. Neither was it able to handle.
Please is there some other way to get these content?