我正在创建一个联系人通讯录,并希望为用户添加上传联系人图片并将其保存到服务器的功能。下面是客户端代码
public class FileUploadDialog extends Composite
{
private VerticalPanel panel = new VerticalPanel();
private DecoratorPanel dPan = new DecoratorPanel();
public FileUploadDialog()
{
initWidget(dPan);
dPan.setWidget(panel);
// create a FormPanel
//final FormPanel form = new FormPanel();
// create a file upload widget
final FileUpload fileUpload = new FileUpload();
// create labels
Label selectLabel = new Label("Select a file:");
// create upload button
Button uploadButton = new Button("Upload File");
// add a label
panel.add(selectLabel);
// add fileUpload widget
panel.add(fileUpload);
// add a button to upload the file
panel.add(uploadButton);
uploadButton.addClickHandler(new ClickHandler()
{
@Override
public void onClick(ClickEvent event) {
// get the filename to be uploaded
String filename = fileUpload.getFilename();
if (filename.length() == 0) {
Window.alert("No File Specified!");
} else
{
System.out.println("submited");
}
}
});
}
}
我的问题是如何使用 rpc 调用将图像文件发送到服务器?