Reputation: 155
I try to get $request->image->getClientOriginalName()
but it returns
"Call to a member function getClientOriginalName() on string"
When I call $request->image
it returns a string of the image name on my disk like picture.png
How to get a file object?!
Upvotes: 0
Views: 369
Reputation: 3125
I would suggest going through this link; which gives an in depth overview of how handling files from requests work in laravel.
Although you can always do the below:
$file = $request->file('photo');
or
$file = $request->photo;
I would suggest you going through the documentation and changing the version of laravel as per your needs.
Upvotes: 0
Reputation: 1971
You could use:
$request->file('image')->getClientOriginalName();
Upvotes: 0
Reputation: 32048
First, your form need to have enctype="multipart/form-data"
in it. Make sure it looks like this:
<form action="your/path" method="post" enctype="multipart/form-data">
Then check that your input has type="file"
:
<input type="file" name="image">
Then access your file in your controller via:
$request->file('image')->getClientOriginalName();
Upvotes: 4