i am trying to upload image path in mysql database and show it in homescreen .currently i am having difficulty in storing image path in my sql database and image in project folder .i have made following effort but it doesnot store correct path of image in databse
const saveProduct = async (e) => { e.preventDefault();
await axios.post('http://localhost:3000/products' ,{
image:image,
title:title,
price:price
});
history.push("/");
}
function handleChange(e) {
setImage(URL.createObjectURL(e.target.files[0]));
};
<div className="App">
<label className="label">Upload Image</label>
<input type="file" onChange= {handleChange} />
<img src={image} alt=''/>
</div>