html - How to upload image from <image src> tag in javascript? -


i have image tag on webpage below.

<image src='http://xxxxxx.jpg'/> 

now want image , upload remote http server in javascript. value of image url variable defined in javascript http api call. want upload image remote server below. how can set value on 'how_to_set_this_value' in case?

axios({     url: backendserveraddress + '/user/upload_photo',     method: 'post',     timeout: 30000,     headers: {       'access_token': token     },     data:  how_to_set_this_value,   }).then(response => {     console.log('update photo response '+ response)    }).catch(response=>{     console.log('failed upload photo')    }) 

var filedata = document.getelementbyid('#idofyourfileinputelement').files[0];  var formdata = new formdata(); formdata.append('name_offile_field_of_your_choice',filedata); formdata.append('some_field_other_than_file',valueofthatfield);  var how_to_set_this_value = formdata; 

after request server doing @ server side can access in php

$_files['name_offile_field_of_your_choice] $_post['some_field_other_than_file] 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -