Image upload processing in "Juincen" Web Jquery+ajax+springmvc

Source: Internet
Author: User

Today there is a need to do the project, the page needs to upload a picture, before the resolution, not written down.

In front of the user to select a picture, and then can preview, and then upload, I resolved.

Preview:

There is an ordinary input tag in the HTML, id:uploadfile

<type= "file"  ID= "UploadFile"/>

There is also an IMG tag that can be previewed, and this img now has no src attribute, Id:imgpreview

<width= " +" height= "  ID"= "Imgpreview" />

Then, in JS, listen for this input change event (after selecting the image)

/* * * Select File to start execution */ $ (' #uploadFile '). Change (function  () {        //  get the first element        of a filelist var f = document.getElementById (' UploadFile '). Files[0];         var src= window. Url.createobjecturl (f);        $ ("#imgpreview"). attr ("src", src);        Console.log (SRC); // look at what this can be viewed as a thing });

Then you can implement the preview!

Upload:

(not finished to update ~)

Juincen image upload processing in the Web Jquery+ajax+springmvc

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.