Uploading images to the /public directory
Answered
ABUL KALAM posted this in #help-forum
Hi. I am working with NextJS 14. I want to put images input by the user in the
Uploading images on a third party is not an option since client requires to put them in the
/public directory. It works fine on the localhost but not if I deploy it on vercel or heroku.Uploading images on a third party is not an option since client requires to put them in the
/public directory.Answered by B33fb0n3
that's not, what you want to hear: you should use a third party for storing the images. Also for serving you should use a third party.
The good thing is, for the client it still looks like he's using the
Well, the services that I am using (third party) to serve files allowes me to choose my own custom domain. And like that I just need to do that and can use my custom domain.
If your third party does not allow to set your own custom domain, add an entry in your domain registy that points to the provider that serves the files.
The third party that stores my files just create a folder
https://yourdomain.com/public/thefile/yoursearch/for.png
The good thing is, for the client it still looks like he's using the
/public folder. How?Well, the services that I am using (third party) to serve files allowes me to choose my own custom domain. And like that I just need to do that and can use my custom domain.
If your third party does not allow to set your own custom domain, add an entry in your domain registy that points to the provider that serves the files.
The third party that stores my files just create a folder
/public and you after that you have: https://yourdomain.com/public/thefile/yoursearch/for.png
3 Replies
@ABUL KALAM Hi. I am working with NextJS 14. I want to put images input by the user in the `/public` directory. It works fine on the `localhost` but not if I deploy it on **vercel** or **heroku**.
Uploading images on a third party is not an option since client requires to put them in the `/public` directory.
that's not, what you want to hear: you should use a third party for storing the images. Also for serving you should use a third party.
The good thing is, for the client it still looks like he's using the
Well, the services that I am using (third party) to serve files allowes me to choose my own custom domain. And like that I just need to do that and can use my custom domain.
If your third party does not allow to set your own custom domain, add an entry in your domain registy that points to the provider that serves the files.
The third party that stores my files just create a folder
https://yourdomain.com/public/thefile/yoursearch/for.png
The good thing is, for the client it still looks like he's using the
/public folder. How?Well, the services that I am using (third party) to serve files allowes me to choose my own custom domain. And like that I just need to do that and can use my custom domain.
If your third party does not allow to set your own custom domain, add an entry in your domain registy that points to the provider that serves the files.
The third party that stores my files just create a folder
/public and you after that you have: https://yourdomain.com/public/thefile/yoursearch/for.png
Answer
ok. Thank you!
happy to help