js通过url上传文件

var xhr = new XMLHttpRequest();
xhr.open('GET', "http://abc/a.jpg");
xhr.responseType = 'blob';
xhr.onload = function(){
var content = xhr.response;
var blob = new Blob([content]);//blob.type=''
var file2 = new File([blob], 'test.png', {type: 'image/png'});
let formData = new FormData();
formData.append('file',file2 );
//上传接口
}

原文地址:https://www.cnblogs.com/xienb/p/13408072.html