JavaScript-how to get uploaded picture information via JS (temporary save path, name, size) and then pass Ajax to the backend

Source: Internet
Author: User
Tags readfile
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);
  • 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.