Answer the question
In order to leave comments, you need to log in
How to upload image to server in laravel?
Hello everyone, I’m making blog articles, I need to upload a preview image for the article, there is a separate column in the post table where the image name is stored, everything is simple, but I can’t upload the image itself to the server, please tell me what the problem is.
Form:
the form itself is large, because is a form for editing an article
<form action="{{ route('posts.update',$item->id) }}" method="POST" enctype=«multipart/form-data»>
.....
<div class="custom-file">
<input type="file" class="custom-file-input" id="customFile" name="prevyu">
<label class="custom-file-label" for="customFile" placeholder="Select file"></label>
</div>
......
</form>
$prevyu = $request->file('prevyu')->store('public/img');
Answer the question
In order to leave comments, you need to log in
The problem was the quotes in the form: method="POST" enctype="multipart/form-data"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question