简体   繁体   中英

How to link images from outside of the next js project folder

I'm working on a project where I'm node.js and express for the back-end and next js for the front-end.

I have a form where users can create new products every product has an image.

I'm using multer for image uploads and saving the images inside the uploads folder.

In next js I'm using an image path like this:

/uploads/imag-name.png

But I'm getting could not load the image.

here's my folder structure

Website
--------
  client
  -------
    components
    pages
    public
    styles
    ...

  uploads
  -------
    image-name.png
    ...

  server
  ------
    config
    controllers
    middlewares
    models
    routes
    utils
    server.js

Move your uploads directory into your client/public director so the structure should look like this

Website
--------
  client
  -------
    components
    pages
    public
      uploads
         -------
         image-name.png
    styles
    ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM