Javascript-how to get the uploaded image information (temporary save path, name, size) through js and then pass it to the backend through ajax

Source: Internet
Author: User
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 useFormDataAjax upload

var file = document.getElementById("c_pic").files[0];var file_json = JSON.stringify(file);$.post('',file_json);
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.