Reputation: 663
I'm trying to upload videos (i have also tried images) through a REST api in Laravel through Postman.
So far I have tried to do the simplest upload, but nothing seems to work. I'm doing a POST request to http://localhost:8000/api/videos using the "form-data" option in PostMan and setting the "file" option so i can use the "browse" button to find a file on my PC and calling the file "file".
In the controller i'm doing this:
return $request->file('file')->getClientOriginalExtension();
But i get the error "Call to a member function getClientOriginalExtension() on null". I have also tried:
return Input::file('file')->getClientOriginalExtension();
But it's the same result.
Anyone have an idea what i'm doing wrong?
Upvotes: 4
Views: 8276
Reputation: 663
Okay, I found out what was wrong. When choosing "form-data" in PostMan, it automatically sets a header "Content-Type: application/x-www-form-urlencoded".
I just removed the header, and everything worked :)
Upvotes: 9