Hi, I am new to smartgwt.
I would like to know when I am using FileItem to upload file, how can I filter the file size.
If the file size is exceed to certain size (e.g. 209715200 bytes), the file cannot be upload.
My code is below:
FileItem imageItem = new FileItem("image");
imageItem.setWidth(100);
imageItem.setTitle("Upload");
imageItem.setHint("(Try upload more than 2MB, then you gonna to die)");
imageItem.setRequired(true);
imageItem.setTitleAlign(Alignment.LEFT);
imageItem.setAlign(Alignment.LEFT);
imageItem.setAttribute("accept", "image/*");
ButtonItem save = new ButtonItem("save", "Save");
save.addClickHandler(new ClickHandler(){
public void onClick(ClickEvent event) {
form.saveData(new DSCallback(){
public void execute(DSResponse response, Object data, DSRequest request) {
if(response.getStatus() >= 0) {
form.editNewRecord();
}
}
});
}
});
I would like to know when I am using FileItem to upload file, how can I filter the file size.
If the file size is exceed to certain size (e.g. 209715200 bytes), the file cannot be upload.
My code is below:
FileItem imageItem = new FileItem("image");
imageItem.setWidth(100);
imageItem.setTitle("Upload");
imageItem.setHint("(Try upload more than 2MB, then you gonna to die)");
imageItem.setRequired(true);
imageItem.setTitleAlign(Alignment.LEFT);
imageItem.setAlign(Alignment.LEFT);
imageItem.setAttribute("accept", "image/*");
ButtonItem save = new ButtonItem("save", "Save");
save.addClickHandler(new ClickHandler(){
public void onClick(ClickEvent event) {
form.saveData(new DSCallback(){
public void execute(DSResponse response, Object data, DSRequest request) {
if(response.getStatus() >= 0) {
form.editNewRecord();
}
}
});
}
});
Comment