0

Choose a client's File, copy to server and print the content in console.

asked 2013-07-29 21:57:58 +0800

ZoeTripp gravatar image ZoeTripp
1

updated 2013-07-30 05:37:30 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

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.

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2013-07-30 03:56:07 +0800

cor3000 gravatar image cor3000
6280 2 7

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

link publish delete flag offensive edit
0

answered 2013-07-30 05:43:22 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

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.

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2013-07-29 21:57:58 +0800

Seen: 28 times

Last updated: Jul 30 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More