shell 接收文件后端 ——busybox
while read kos do [ "${#kos}" -le "1" ]&&break; koss="$kos $koss" done zj=$(echo "$koss"|awk '{IGNORECASE=1}/Content-Length:/{gsub("\r","",$2);print$2}') //获取文件大小 vn=0 vv=0 while read filehead do [ "${#filehead}" -le "1" ]&&break; [ "$(echo "$filehead"|grep ^-)" ]&&vv=${#filehead} vn=$((${#filehead}+vn)) done //获取文件信息头并且计算文件实际大小 dd bs=1 count=$((zj-vn-vv-10)) of=/tmp/oopp 2>/dev/null //通过dd读取流导出到文件 #gg=$(dd bs=1 count=$vv 2>/dev/null)web前端
<script type="text/javascript"> let button = document.getElementById('upload') button.addEventListener('click', event => { let fileObj = document.getElementById('img_file').files[0] if (fileObj) { let url = 'api/upload.xjs' let formData = new FormData() formData.append('image', fileObj) let xhr = new XMLHttpRequest() xhr.onload = function () { console.log('ok') console.log(JSON.parse(xhr.responseText)) } xhr.onerror = function () { console.log('fail') } xhr.open('post', url, true) xhr.send(formData) } else { console.log('请选择文件') } }) </script>
评论