是我这个put形式传递的参数有问题吗?put形式传递文件不能这样吗?望大神能为我解答一二。<!DOCTYPE html><html><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title></head><body> <input id="file" name="img" type="file"/></body><script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script><script> $('#file').on('change',function(){ var formData = new FormData(); formData.append("img", $("#file")[0].files[0]); console.log(formData,'form', $("#file")[0].files[0]) $.ajax({ url: "xxx", type: "put", data: formData, processData: false, contentType: false, xhrFields:{withCredentials: true}, success: function(response){ console.log(response) // 根据返回结果指定界面操作 } }); })</script></html>
添加回答
举报
0/150
提交
取消