How JavaScript determines file upload type instance sharing

Source: Internet
Author: User

Share the JavaScript method for determining file upload types, which can trigger onchange events for duplicate content.

How JavaScript determines the type of file upload:
A feature is used when uploading files, using the input tag of the HTML element to implement:

<input id= "ImageFile" name= "ImageFile1" accept= "image/jpg,image/jpeg,image/png,image/bmp,image/gif" type= "file" title= "Click to select File" onchange= "Imagesubmit (this,0);" />

The onchange event upload image is triggered immediately after the picture is selected, but repeating the same picture does not trigger the Onchang event, the workaround is as follows:

functionif (imageType = = "0"// related processing code ...) // www.yuju100.com // Resolve upload the same picture does not trigger onchange event var nf = Obj.clonenode (true); Nf.value= "; Obj.parentNode.replaceChild (NF, obj );}}

The CloneNode () method is used to create an identical copy of the call to the node, and True indicates that a deep copy is performed, that is, the copy node and the entire child node tree, in the case of false parameters, perform a shallow copy, that is, the node itself is copied only.

The copy of the node returned after replication belongs to the document, but does not specify a parent node for it. Www.jbxue.com

Therefore, this copy of the node becomes an "orphan" unless it is added to the document by AppendChild (), insertbefore (), or replacechild ().

How JavaScript determines file upload type instance sharing

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.