input file upload multiple files

秋建义
2023-12-01
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"  dir="ltr">
<head>
    <title>input file upload multiple files</title>
</head>
<body>
<input type="file" multiple="" name="filesToUpload" id="filesToUpload" οnchange="makeFileList();">
<p>
    <strong>Files You Selected:</strong>
</p>
<ul id="fileList"><li>No Files Selected</li></ul>
<script type="text/javascript">
    function makeFileList(){
        var input = document.getElementById("filesToUpload");
        var ul = document.getElementById("fileList");
        while (ul.hasChildNodes()){
            ul.removeChild(ul.firstChild);
        }
        for(var i = 0; i < input.files.length; i++){
            var li = document.createElement("li");
            li.innerHTML = input.files[i].name;
            ul.appendChild(li);
        }
        if(!ul.hasChildNodes()){
            var li = document.createElement("li");
            li.innerHTML = "No files selected.";
            ul.appendChild(li);
        }
    }
</script>
</body>
</html>

 类似资料:

相关阅读

相关文章

相关问答