D
D
Denis Bukreev2017-09-18 05:03:43
Laravel
Denis Bukreev, 2017-09-18 05:03:43

How to upload and return images using laravel?

So it goes.
I send images to the server via ajax, but I can’t figure out something, how can I get them back in the server response in order to display them to the user?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Budaev, 2017-09-18
@denisbookreev

In the controller that handles saving the image, return a variable containing the path to the file.

public function upload(Request $request) {
$path = $request->file('image')->store('images');
return $path;
}

And read the doc , it has answers to most typical questions.

H
hakkol, 2017-09-18
@hakkol

Save on the server and return the path to the image. Well, you can create img with src with a link to the image.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question