Advertisement
zingga

Untitled

Jul 15th, 2021
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. const onFileChange = event => {
  2. const formData = new FormData()
  3.  
  4. const image = {
  5. type: 'image/jpeg'
  6. }
  7.  
  8. const blob = new Blob([event.target.files[0]], image)
  9. formData.append('file', blob)
  10.  
  11. axios.post('http://localhost:3334/api/v1/fileupload/images', formData, {
  12. headers: {
  13. 'Content-Type': 'multipart/form-data; ',
  14. }
  15. })
  16. .then(response => {
  17. console.log('response =>', response)
  18. })
  19. .catch(err => {
  20. console.log('err =>', err)
  21. })
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement