Problem Description:
The input file upload image is bound to the onchange execution function, which triggers the onchange function when the selected picture is changed. The onchange event is not triggered when we add a picture and preview, when we encounter adding the same picture, or when we add the same picture by deleting it and then adding the same one.
Workaround:
1. The function in the executed onchange finally regenerates a section of input file HTML code to replace the original input file
$ (' #cFile '). ReplaceWith (' <input type= "file" id= "CFile" accept= "image/*" multiple onchange= "javascript: SetImagePreview1 (); "Style=" Filter:alpha (opacity=0); opacity:0;width:30px;height:30px;position:absolute;left:0px; Overflow:hidden; " /> ')
2. Write a function that binds the click event of the input file
Input file Add picture preview Binding onchange Execute function Repeat add do not execute onchange function