0

This is a file upload request from an angular app:

Request:

------WebKitFormBoundaryo5BfYJAUkmJC5BoJ
Content-Disposition: form-data; name="file"; filename="1570306102797.jpg"
Content-Type: image/jpeg


------WebKitFormBoundaryo5BfYJAUkmJC5BoJ--

Header:

POST /api/recipe HTTP/1.1
Content-Type: multipart/form-data
Accept: application/json
Host: test.local
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Origin: http://192.168.0.100:8101
Referer: http://192.168.0.100:8101/recipes
Connection: keep-alive
User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148
Content-Length: 15647436
enctype: multipart/form-data

This is my controller in my Laravel app:

public function store(Request $request)
    {
        return $request->file('file')->getClientOriginalName();
    }

No matter what I try I get a null error as if the request doesn't include the "file" image. Any ideas on how to progress from here?

Christoffer
  • 482
  • 7
  • 32

1 Answers1

0

Don't know what actually in client-side, but try without "Content-Type" in Headers

boolfalse
  • 1,892
  • 2
  • 13
  • 14
  • Thanks for putting me in the right direction. I found the answer here: https://stackoverflow.com/a/39281156/980711 – Christoffer Oct 06 '19 at 17:44