开发者

Add the uploaded txt file to HTML table

Is it possible to append the content of an uploaded text file to开发者_开发知识库 a <table>, and not its name? I guess, I want to open the uploaded txt file, parse and added the content to the table on the same page. Here is where I'm at right now. :(

Thanks so much in advance.


Sadly you can't do this. In order to do something like this you need some server side code.

The main issue is one of security -- local javascript can't look at local files. The upload button can only send the file to the server not the local javascript.

Typically people solve this problem using flash which does not have the same security requirements -- or a local program.


Reading the contents of a file selected by an upload input will be possible with the File API, which has some support in newer browsers (Firefox and more recently Chrome).

On browsers that don't provide this, you'd have to post the form and have the server echo out the content of the file for the script to pick up. (eg post form to iframe and have server response with script to call parent.callback('file content')).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜