-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi guys, I need a huge help.
I'm newbie in this world of programing, and even more in this framework.
I was wondering how to upload some file from a client to a server, not just that but also print the content of the file in console. The situation is that I have two buttons, one "Choose File" where I choose the path from the clients computer and copy it to server, and the second one "Conciliate", where on clicking it must show the content of the selected file in console.
I found this code:
<button label="Choose File">
<attribute name="onClick">
import java.io.File;
import org.zkoss.io.Files;
import org.zkoss.util.media.Media;
import org.zkoss.zhtml.Fileupload;
File dest = new File("C:\\abc.xls");
Media media = Fileupload.get();
println(Fileupload.get);
Files.copy(dest, media.getStreamData());
</attribute>
</button>
but it sends me to another dialog box with three options: Explorer, Upload and cancel, and what I need is that just on clicking my "Choose File" button sends me the box of the Files on the clients Pc to choose it.
I hope you can help me on this, cause I'm loosing my mind.
when I try your example it gives me an error.
a working example is here on zk-fiddle
in this method on the serverside, you can retrieve the content from the UploadEvent.getMedia().getXYZ functions
public void updata(UploadEvent evt) {
lbl.setValue("" + evt.getMedia());
}
please also refer to the File Upload documentation and javadocs
Here you can check the how fileupload work in MVVM now you can see you have all the data into Media
Object now you can print the data into Console and add also save into Database.
Asked: 2013-07-29 21:57:58 +0800
Seen: 28 times
Last updated: Jul 30 '13
How to load markers dynamically on zk gmap
Possible bug in Combobox component
composite component help [closed]
EL in a forEach @command not working?
Different template for each grid row
Cardlayout animation is broken
Grid RowRender slow using 6.5.1 and sizable=true