Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How to filter upload file size?

    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();
    }
    }
    });
    }
    });

    #2
    Hi kelvinhii,

    see this link. No code, only a validator is needed.

    Best regards
    Blama

    Comment

    Working...
    X