简体   繁体   中英

How to upload a image using vaadin

I have a below kind of html

<html>
    <head>
        <title>Upload a file please</title>
    </head>
    <body>
        <h1>Please upload a file</h1>
        <form method="post" action="http://localhost:8080/service/uploadFile" enctype="multipart/form-data">
            <input type="text" name="name"/>
            <input type="file" name="file"/>
            <input type="submit"/>
            <input type="hidden" name="smallSize" value="50x50">
            <input type="hidden" name="mediumSize" value="100x100">
            <input type="hidden" name="largeSize" value="150x150">
        </form>
    </body>
</html>

I want to do it using Vaadin Upload component ?How can I achieve this?

You can't mix normal html pages with vaadin processing the "results".

They way to go would be to embedd vaadin in your html page.

Look here:

https://vaadin.com/de/book/vaadin7/-/page/advanced.embedding.html

I use https://vaadin.com/directory#addon/easyuploads for it. Example:

final UploadField uploadField = new UploadField();
Button b = new Button("Show value");
b.addListener(new Button.ClickListener() {        
    public void buttonClick(ClickEvent event) {
        Object value = uploadField.getValue();
        mainWindow.showNotification("Value:" + value);
    }
});

您可以使用vaadin-upload上传一张具有属性(maxfiles)的图片

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM