您可以使用元素的HTML5
files属性,
<input type="file" />如下所示:
updateList = function() { var input = document.getElementById('file'); var output = document.getElementById('fileList'); var children = ""; for (var i = 0; i < input.files.length; ++i) { children += '<li>' + input.files.item(i).name + '</li>'; } output.innerHTML = '<ul>'+children+'</ul>';}<input type="file" multiple name="file" id="file" onchange="javascript:updateList()" /><p>Selected files:</p><div id="fileList"></div>


