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?

1

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.