Reputation: 177
Is it possible to upload file via request factory? Simple example will be really helpful.
Upvotes: 2
Views: 811
Reputation: 9741
Actually you can!, I have an application doing it already.
Bean
attribute in your app and send it via RF, RPC, etc.Here you have a copy/paste of the most significant code i use:
public final native void readAsDataURL(MyClass that, FileUpload input) /*-{
var files = [email protected]::getElement()().files;
var reader = new FileReader();
reader.onload = function (evt) {
[email protected]::done(Ljava/lang/String;)(evt.target.result);
}
reader.readAsDataURL(files[0]);
}-*/;
It would be a comming-soon feature on my gwtupload library.
Upvotes: 7
Reputation: 121998
IMO RPC
or Request Factory
sense is XMLHttpRequest
, which does not allow you encode
and send local
files to a server
.
You need to write your own servlet
and a GWT FormPanel
.
complete example here with servlet
and its mapping
Upvotes: -1
Reputation: 3238
No.
You need to create a separate file upload servlet. See Basic File upload in GWT.
Upvotes: 0