Image uploading issue in MERN stack
01:34 24 Nov 2022

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
        
{ FormInfo.images = e.target.files;}} multiple />

But I am receiving an empty image object in the backend. Like:

enter image description here

Dear seniors please also share code about how I can upload pics in NodeJS using multer.

reactjs forms axios multer mern