File upload using jQuery's AJAX requires the use of XHR2, supported by modern browsers. If you want to perform file upload using AJAX without a plugin, you need to use theFormDataobject.
Code:
var formData = new FormData(); formData.append("file", file); // Replace "file" with your file input element's name $.ajax({ type: "POST", timeout: 50000, url: url, data: formData, contentType: false, processData: false, // Don't process the form data, leave it as pure binary data success: function (data) { alert('success'); return false; } });
Notes:
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3