Home >Web Front-end >JS Tutorial >js gets and clears the value of input type='file' (sample code)_javascript skills
The upload control () is used to browse and upload files on the client. The path selected by the user can be obtained by the value attribute, but the value attribute is read-only and cannot be accessed through javascript. Assignment, which makes it impossible to clear it through the value="" statement. It is easy to understand why it is read-only. If the value can be assigned at will, then as long as the user opens your web page, you can upload the files on his computer as he likes.
js gets the value of
Method 1:
//Remember the position of file in the old form
var pos=file.nextSibling;
form.appendChild(file);
form.reset();
pos.parentNode .insertBefore(file,pos);
document.body.removeChild(form);
}