In fact, the problem is: how to get the uploaded image information (temporary save path, name, size) through js and then pass it to the backend Using ajax to receive {code ...} the method for uploading images is {code ...} I want to use the ajax post method to pass the information about the uploaded image to the post...
In fact, the problem is: how to get the uploaded image information (temporary save path, name, size) through js and then pass it to the backend through ajax
I use jquery to receive
Uploaded Image
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 transmit the information about the uploaded image to the backend.
The received file is an object file.
How can I convert it to a data format that can be passed using post?
Reply content:
In fact, the problem is: how to get the uploaded image information (temporary save path, name, size) through js and then pass it to the backend through ajax
I use jquery to receive
Uploaded Image
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 transmit the information about the uploaded image to the backend.
The received file is an object file.
How can I convert it to a data format that can be passed using post?
We recommend that you use the uploadfile plug-in to obtain the above information.
Use the uploadfile plug-in or Baidu's webuploader
If html5 is supported, you can useFormData
Ajax upload
var file = document.getElementById("c_pic").files[0];var file_json = JSON.stringify(file);$.post('',file_json);