From the course: Next.js Ecommerce: Build a Shopping Platform from Scratch
Unlock this course with a free trial
Join today to access over 25,200 courses taught by industry experts.
Add image upload - Next.js Tutorial
From the course: Next.js Ecommerce: Build a Shopping Platform from Scratch
Add image upload
So now we want to add the images field, which is going to look like this. And if we choose a file, an image, and we can choose multiple images, and click Open, you'll see the little spinner. And then it will show the image here. And you can keep choosing images if you want. So to do that, we're going to be using the Upload Button component that was exported from this file right here. So we want to bring this into our form. Now before we do that, one thing we have to do is in the validators TS, in the insert product schema, remember we commented these three fields out because we weren't using them. Now we're going to use images, so I'm going to uncomment that. And then we're going to open up the form, which is components admin product form. And we want to import here. We want to import the upload button. So let's say upload button. Now there's a couple options. you want to choose the at slash lib slash upload thing, where we exported it from. Then we want to go down right above the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
-
-
-
(Locked)
Section intro1m 11s
-
(Locked)
Get products for admin page8m 24s
-
(Locked)
Display products7m 55s
-
(Locked)
Delete products4m 16s
-
(Locked)
Create and update actions8m 30s
-
(Locked)
Create product page and form9m 35s
-
(Locked)
Form fields and slugify13m 27s
-
(Locked)
Create product form submission6m 23s
-
(Locked)
Uploadthing configuration8m 9s
-
(Locked)
Add image upload12m 56s
-
(Locked)
Product cleanup7m 57s
-
(Locked)
Is featured banner8m 55s
-
(Locked)
Product update form9m 57s
-
(Locked)
-
-
-
-
-
-