Skip to content

Product Photo Upload

Compare
Choose a tag to compare
@ahmadhuss ahmadhuss released this 07 Apr 08:41
· 22 commits to master since this release

Now, We can upload a photo for the product, and a validation rule has been added.

$path = $request->file('photo')->store('photos', 'public');

Validation rule:

'photo' => 'required|image|mimes:jpeg,png,jpg|max:2048',

Storage Strategy because of this :

$path = $request->file('photo')->store('photos', 'public');

We are storing an uploaded photo in the storage/app/public/photos directory and photo saved in the database with the following path photos/${imagePath}.jpg.

After that, we have used the artisan CLI and made the symlink (shortcut) of the storage/app/public directory to /public/storage.

Finally, we can publicly access photos in blade with following syntax asset("storage/$product->photo").