本文介绍了简单的客户端文件处理,无需刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于以下用例,什么是干净简单的 JavaScript 解决方案:

What is a clean and simple JavaScript solution for the below use case:

在网页上,用户从本地文件系统中选择并上载文本文件,但不是将文件加载到服务器,而是打开客户端javascript代码并处理文件内容,并将结果写入同一页面而不刷新页面。

On a web page, user selects and uploads a text file from her local filesystem, but instead of loading the file to a server, the client-side javascript code opens and processes the content of the file, and writes the results to the same page without refreshing the page.

注意:我不需要保留文件的内容 - 如果用户关闭页面,那么内容就会丢失,这很好。一切都应该发生在客户端的页面上 - 无需触摸服务器。

Note: I don't need to persist the content of the file - if the user closes the page then the content is lost and that is fine. Everything should happen on the page on the client side - no need to touch the server.

如果有一些轻量级 JQuery 这个插件,很想知道!

If there is some lightweight JQuery plug-in for this, would love to know!

推荐答案

你所说的是HTML5文件API。我不确定描述它的最佳链接是什么,但这可能有所帮助。

What you're talking about is the HTML5 File API. I'm not sure what is the best link to describe it, but this might help. https://developer.mozilla.org/en-US/docs/Using_files_from_web_applications

这篇关于简单的客户端文件处理,无需刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 05:06
查看更多