const response = await fetch(`http://${serversIP}/upload/${encodeURIComponent(saveMediaPath)}`, {
method: 'POST',
body: formData,
headers: {
'Content-Type': 'multipart/form-data',
}
});
const storage = multer.diskStorage({
destination: (req, file, cb , err) => {
let savePath = imagesDir
//console.log("its",req.params.filePath)
if(req.params.filePath!="startPoint"){
savePath = path.join(imagesDir,req.params.filePath)
}
cb(null, savePath); // Save all files to the 'images' directory
},
filename: (req, file, cb) => {
cb(null, Date.now() + path.extname(file.originalname));
}
});
i am trying to send the destination as a url param
in order to save it where it needs to be but almost always , the first time i am fetching fails but after the first time works flawless , any ideas
i have tried
–> send it as header
–> append it in the json
i dont know how to solve it , and i cant find something usefull on the internet
any ideas would be more than welcomed
New contributor
Γιώργος ΟΙΚ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.