是否有可能从< input type = file>截取文件?在JavaScript? [英] Is it possible to intercept the file from a <input type=file> in javascript?

查看:130
本文介绍了是否有可能从< input type = file>截取文件?在JavaScript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以读取使用文件输入控件选择的文件的内容?我希望这样做:

 < input type =fileid =fileInputonblur =readFile(this )/> 

< script language =javascript>
函数readFile(file){
document.write(file);
}
< / script>

有这样的可能吗?或者文件上传只是将文件发送到服务器。 nofollow noreferrer> Firefox ,但它不是标准化的,所以在浏览器中不可移植(例如,WebKit不支持它)。最好的办法是将文件上传到服务器,然后使用 XMLHTTPRequest 来下载。


Is it possible to read the content of a file that has been selected with a file input control? I wish to do something like:

<input type="file" id="fileInput" onblur="readFile(this)"/>

<script language="javascript">
   function readFile(file) {
     document.write(file);
   }
</script>

Is anything like this possible? or does the file upload just send the file to the server.

解决方案

It is possible in Firefox, but it is not standardized, so it is not possible portably across browsers (for instance, WebKit does not support it). Your best bet would probably be to upload the file to the server, and then download it again using an XMLHTTPRequest.

这篇关于是否有可能从&lt; input type = file&gt;截取文件?在JavaScript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆