Image uploading issue in MERN stack
I am arslan chaudhry Mern stack develpore. I am an issue for the last 4 days. I am unable to upload images in the MERN stack. I am using Axios in ReactJS for this purpose. I have created a state and then use it post request. Like This:
const [FormInfo, setFormInfo] = useState({productName:"",image:""})
//function for setting state
let names;
const setInputsData = (e) => {
names = e.target.name;
setFormInfo({
...FormInfo,
[names]: e.target.value,
});
};
const submiteDataNow = async (e) => {
e.preventDefault();
const res = await axios.post("/Create_Post", FormInfo);
};
FORM
But I am receiving an empty image object in the backend. Like:
Dear seniors please also share code about how I can upload pics in NodeJS using multer.
