用Javascript将文件内容读入Textarea [英] Read File Contents into Textarea in Javascript

查看:89
本文介绍了用Javascript将文件内容读入Textarea的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本区域,一个文件浏览器控件和一个加载按钮.当用户选择一个文件并单击加载"按钮时,我想在文本区域中显示所选文件的内容.我希望此解决方案可以使用Javascript设计.它应该可以在Internet Explorer,FireFox和Chrome上运行.

I have one textarea, one file browser control, and one load button. When the user selects a file and clicks the load button, I want to display the contents of the selected file in the textarea. I would like this solution to be designed in Javascript. It should work on Internet Explorer, FireFox, and Chrome.

推荐答案

我非常确定,如果不先将数据传输到服务器,就无法使用JavaScript进行此操作.但是,您可以使用AJAX将其传输到服务器.请参阅此处: http://stackoverflow.com /questions/527955/how-can-i-up-up-up-file-using-javascript-without-a-postback

另外,您可以使用Flash和Java(注意:不是JavaScript)来完全在客户端上执行上传.
I''m pretty sure this cannot be done with JavaScript without the data traveling to the server first. However, you can have it travel to the server using AJAX. See here: http://stackoverflow.com/questions/527955/how-can-i-upload-a-file-using-javascript-without-a-postback

Alternatively, you can use Flash and Java (note: not JavaScript) to perform the upload entirely on the client.


这篇关于用Javascript将文件内容读入Textarea的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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