Guilherme Moreira
Guilherme Moreira

Reputation: 121

Laravel -How to store image file provided by user

so I have a simple HTML file insert box,

<input id="image" type="file" name="image" value="{{ old('image') }}" accept="image/gif, image/jpeg, image/png" class="black-font">

but after inserting the image and going to a different page, the website doesn't save the image, which means I cannot use it later. I've looked around for some ways to get around this but I couldn't find anything that worked. is there any way I can store the file? Or another alternative that makes me be able to use them in another page of the website?

If it helps, I have a SQL table called "event" with an attribute image where I'd like to store the link/path to the image provided.

Upvotes: 1

Views: 156

Answers (1)

Muh Raswan Sualdi
Muh Raswan Sualdi

Reputation: 81

By default, public disks use local drivers and store these files under storage/app/public. To access them via the web, you need to create a symbolic link from public/storage to storage/app/public. Go into the .env file, create a variable called FILESYSTEM_DRIVER, and set it to the public, as shown below:

FILESYSTEM_DRIVER=public

Next, use the command below in order to create the symbolic link.

php artisan storage:link

Upvotes: 5

Related Questions