Guys this will not going to work on production so don't waste your time here, Use a third party service like cloudinary or you can use an express server for storing static data in local directory.
In development mode maybe It works but in production I think it doesn't work Read nextjs documentation: Good to know: The directory must be named public. The name cannot be changed and it's the only directory used to serve static assets. Only assets that are in the public directory at build time will be served by Next.js. Files added at runtime won't be available. We recommend using a third-party service like AWS S3 for persistent file storage.
Absolutely you need 1 step to access your image after image uploaded. 1. Re build your app, so image will detected 😁 or ... 2. Create an API to serve your image. Example: Create api file usual /pages/api/images/[filename].jsx import fs read data file using query filename Send the image to client 😁
i got an issue here, after deploy website on server, public directory not recognize, all images goes to .next/static/media. for having those picture you should run command npm run build every time you upload new image. is there any way to solve this problem?
Dear sir , I m from Pakistan... Please make a video with next. Js Full stack Mongodb Add title, Description, category with Image With Same work PDF file upload and Videos Add from front end and back End Then Image Display, PDF file download and Videos play work
I want to send form data containing file, fields to my node js API, from NextJs Api. My react component posts on Nextjs api route, then it forwards data to nodejs api. How can i implement this ??
Does anyone know how one would go about uploading different images in different folders? (specific to the user uploading it?) for example /public/images/{user.id}
guys, i'm having a bad time with a project that has a close deadline, and i need to upload the files into the public folder but i can't understand a single thing about typescript. Can you suggest something(a video, a blog ...) that shows how to do the same thing with next and javascript instead of ts. thank you so much
This is great. Thanks. Can you also tell me how can I send the same image to API Endpoint (External) where I'd like to edit the image for example and get the response from that server?
Thats a little extra work but here I did a video about all those things you can check this out ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-m7uO85p-c0Q.html this is the part where we are uploading image to the cloudinary using node js. You can do this same inside your next js api
@@fsniraj Thank you for your suggestion. I watched the video but I cound't make the code to work. If you could show how to write the code in next js api that would be great. If not, could you please direct me to some post or thread which could help me solve this issue. Anyways thanks for your awesome videos.
As @isbelmont mentioned: Read nextjs documentation: Good to know: The directory must be named public. The name cannot be changed and it's the only directory used to serve static assets. Only assets that are in the public directory at build time will be served by Next.js. Files added at runtime won't be available. We recommend using a third-party service like AWS S3 for persistent file storage. So that's a hard constraint