4

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?

bsgrd
  • 633
  • 1
  • 9
  • 26

1 Answers1

9

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 :)

bsgrd
  • 633
  • 1
  • 9
  • 26