我使用數(shù)組添加或刪除要上傳的 mutli 文件,當我想通過 ajax 和 formdata 上傳文件時,它在我的 php 文件中不起作用并且我無法在此處捕獲上傳的文件是我的上傳功能。var upload_images=[];//here where i saved filesfunction upload_images(){ const fd = new FormData(); const xhr = new XMLHttpRequest(); fd.append('upload_images[]',upload_images[]); xhr.open('POST','upload.php', true); xhr.send(fd); xhr.onreadystatechange = function() { if (xhr.readyState == 4 && xhr.status == 200) { upload_images=[]; let i=0;i2=upload_url.length; for(let i=0;i<i2;i++){URL.revokeObjectURL(upload_url[i]);} upload_url=[]; } }; xhr.upload.addEventListener("progress", function(e) { if (e.lengthComputable) { progress_bar.value=Math.round((e.loaded * 100) / e.total); } }, false);}
Formdata不上傳多張圖片
繁華開滿天機
2023-04-01 16:30:03