'My Image not open when i work with formData in Reactjs
I work with ReactJs and I have a problem when I try to make a PDF post with FormData.
The image is well stored in the server, but it does not open. The link seems to be wrong and I don't know what I missed, could someone help me Please ?
Thank you !
const instance2 = axios.create({
baseURL: config.urlMarketplaceApi,
timeout: 30000,
headers: {
TOKEN: config.env === 'test' ? config.tokenTests : decodeURIComponent(cookies.get('token') ?? ''),
'APP-ID': config.marketplaceAppId,
// 'Content-Type': 'multipart/form-data',
},
});
let file2: {} | any = {};
const handleUploadFile = (e: any) => {
file2 = e.target.files[0]
formDataInfo.append('file', file2)
}
const formDataInfo: FormData | any = new FormData()
const handleSendFile = (e: any) => {
setMonCompteur(1)
}
useEffect(() => {
(async () => {
if(monCompteur == 1) {
const postingData = await MarketplaceRequests.usersSetResume(formDataInfo).then(res => console.log(res, 'Upload réussi')).catch((err) => console.log(err, 'une erreur est survenue'))
return postingData
}
})()
}, [monCompteur])
<form action="">
<input type="file" name="file" onChange={(e) => handleUploadFile(e)} />
<button type="button" onClick={(e) => handleSendFile(e)}>Upload</button>
</form>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
