从GWT文件上传输入创建字节数组 [英] Create Byte Array from GWT File upload Input

查看:110
本文介绍了从GWT文件上传输入创建字节数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个GWT客户端,我希望用户使用FileUpload控件选择一个文件,并且通过HTTP流将其发送到Web服务。

文件上传控件包含一种获取所选文件的文件路径的方法。 然后我如何获得该文件并将其转换为字节数组?



对于如何将文件转换为我的Web服务,不太确定Byte数组是否可以工作...

解决方案

如果您想在GWT中转换文件,意味着在浏览器中。无法在浏览器中仅使用JavaScript。 FileUpload 是一个html输入类型文件上传只能在提交表单时将文件发送到服务器。出于安全原因,浏览器无法读取文件系统中的文件。 (你可以使用像flash插件这样的插件来实现它,尽管我手边没有示例)。



如果您想将文件内容发送给您webservice,你需要或直接上传到web服务或发送到另一台服务器,将其转换并从该服务器提交到您的web服务或写或找到一些(闪光)插件,它为你做。


I have a .NET web service that takes a byte array.

I have a GWT client where I want the user to select a file using the FileUpload control and send it to the web service via HTTP stream.

The file upload control contains a method to get the file path of the selected file. How can I then get that file and convert it to a byte array?

I'm open to suggestions on how to get the file to my web service, not quite sure the Byte array will work...

解决方案

If you want to convert the file in GWT, meaning in the browser. It's not possible to do in the browser using only JavaScript. FileUpload is a html input type file upload can only send the file to a server as in submit a form. For security reasons browsers can't read files from your file system. (You could use a plugin like a flash plugin to get it to work, although I have no examples at hand).

If you want to send the file content to your webservice, you need to or upload it directly to the webservice or send it to another server, convert it and from that server submit it to your webservice or write or find some (flash) plugin that does it for you.

这篇关于从GWT文件上传输入创建字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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