Search code examples
javazk

Why not run the upload command in ZK?


in my zul i use:

<cell colspan="2">
   <button label="Upload image" upload="true" onUpload="@command('uploadImage', uploadEvent=event, window = editTranslation)"/>
</cell>

And in viewmodel i use this:

@Command
@NotifyChange({"leadImage", "uploadMessage"})
public void uploadImage(@BindingParam("uploadEvent") UploadEvent event, @BindingParam("window") Window win) {
    Clients.showBusy(win, "Képfeldolgozás ...");
    System.err.println("uploadimage");
    Media media = event.getMedia();
    if (media instanceof org.zkoss.image.Image) {
        saveImageToDisk(media);
        Clients.clearBusy(win);
    } else {
        Clients.clearBusy(win);
        Messagebox.show("Ez nem egy kép: "+media, "Error", Messagebox.OK, Messagebox.ERROR);
    }
}

But not run the uploadImage command if i click the button and choose an image...it shows: C:\fakepath\desert.png for example...what can be a problem? I use spring security can be cause this?


Solution

  • In spring security xml i have to add this lines:

        <headers>
            <frame-options policy="SAMEORIGIN"/>
        </headers>