in fact, the problem is: How to get uploaded image information via JS (temporary save path, name, size) and then passed through Ajax to the backend
I'm using jquery to receive
Uploaded images
The method used is
var input = document.getElementById("c_pic");input.addEventListener('change',readFile,false);function readFile(){ var file = this.files[0]; }
I want to use the Ajax Post method to upload the relevant information of the image to the backend
The received file is an object file
How do I convert to a data format that can be delivered using post?
Reply content:
In fact, the problem is: How to get uploaded image information via JS (temporary save path, name, size) and then passed through Ajax to the backend
I'm using jquery to receive
Uploaded images
The method used is
var input = document.getElementById("c_pic");input.addEventListener('change',readFile,false);function readFile(){ var file = this.files[0]; }
I want to use the Ajax Post method to upload the relevant information of the image to the backend
The received file is an object file
How do I convert to a data format that can be delivered using post?
It is recommended to use the UploadFile plug-in above the information can be obtained
Via UploadFile plugin or Baidu's Webuploader
If you support HTML5, you can use FormData
ajax to upload
var file = document.getElementById("c_pic").files[0];var file_json = JSON.stringify(file);$.post('',file_json);