Javascript Javascript文件上传
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6191792/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Javascript file upload
提问by Jeff
In most browsers, an input type="file" has the following files property:
在大多数浏览器中, input type="file" 具有以下 files 属性:
document.getElementById("my-input").files
This can be used to detect a file is uploaded, and get the file. However, it looks like the files attribute doesn't exist in IE9.
这可用于检测文件是否已上传,并获取该文件。但是,看起来 IE9 中不存在 files 属性。
Added:
添加:
In jQuery, you can do...
在 jQuery 中,你可以做...
$("#my-input").val()
to read the file name. What about getting the files contents?
$("#my-input").val()
读取文件名。获取文件内容怎么样?
采纳答案by Rodrigo
Use jQueryand this plugin.