Closed tharindu-dm closed 1 month ago
check these functions:
upload by link
async function addPhotByLink(ev) {
ev.preventDefault();
const { data: filename } = await axios.post("/upload-by-link", {
link: photoLink,
});
setAddedPhotos((prev) => {
return [...prev, filename];
});
setPhotoLink("");
}
uploadFile
function uploadPhoto(ev) {
const files = ev.target.files;
const data = new FormData();
for (let i = 0; i < files.length; i++) {
data.append("photos", files[i]);
}
axios
.post("/upload", data, {
headers: { "Content-type": "multipart/form-data" },
})
.then((response) => {
const { data: filenames } = response;
setAddedPhotos((prev) => {
return [...prev, ...filenames];
});
});
}
upload is working but, now it doesn't show the image. image is not rendered to the site
src={"http://localhost:3000/api" + link }
generates: http://localhost:3000/uploads/uploads\62887632cb58dd17376a63767dda5329.jpg find where the uploads\3528305y285.jpg comes from
also check whether renameing works
somehow the image name seems like it got an encrypted or hashed. doesn't include current date
IT SHOULD BE LOCALHOST:4000 !!!
when uploading images using link or from device, Uncaught runtime errors: