js上传excel

 formdate("fileInput")} accept=".csv, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"/>   
      
function formdate(id){
        document.getElementById(id).addEventListener('change', uploadFile, false);
        function uploadFile(e){
            console.log(e.target.files[0]);
            var file = e.target.files[0];
            var formData = new FormData(id,file);
            formData.append('name',attribute)            
            var xhr = new XMLHttpRequest();
            xhr.open('POST', 'url', true);
            xhr.send(formData);
        }

你可能感兴趣的:(js上传excel)