上传word文档
我需要从用户上传的word文档中提取文本。我得到了代码来从位于我的文档中提取单词米/克。但我的要求是允许用户使用上传按钮上传自己的文档阅读该文档(我不需要保存该文档)。你能建议我该怎么做吗?我需要知道单击上传按钮后需要发生什么。
I need to extract text from the word document uploaded by the user. I got the code to extract words from a document located on my m/c. But my requirement is to allow users to upload their own document using the upload button & read that document(I dont need to save that document). Can you please suggest me how to go about this? I need to know what all need to happen after clicking the upload button.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当用户上传文件时,获取关联的
InputStream
并将其存储到变量中,例如inputStream
。然后只需使用示例代码,并将此行:...替换为:
应该足够简单,假设您已经有一个
Servlet
来处理上传。编辑:
以下是 servlet 如何工作的基础知识,假设您使用 commons-fileupload 来解析上传:
When the user uploads their file, grab the associated
InputStream
and store it to a variable, likeinputStream
. Then just take the example code, and replace this line:...with something like:
Should be simple enough, assuming that you already have a
Servlet
in place to handle the upload.Edit:
Here are the basics of how the servlet could work, assuming that you are using commons-fileupload to parse the upload: