0

File uploading problem with Fileupload.get(-1)

asked 2011-09-06 01:26:06 +0800

bhushan2169 gravatar image bhushan2169
138

<button label="Upload" onClick="Fileupload.get(-1);" onUpload="processMedia(event.getMedias());"/>
<zscript deferred="true"><![CDATA[

import org.zkoss.util.media.Media;

public void processMedia(Media[] media) {

if (media != null)
{
for (int i = 0; i < media.length; i++)
{
System.out.println("Media is not null::>"+media.getName());
}
}
else
System.out.println("Media is null");
}
]]></zscript>
above is my code it is getting executed successfully bt it doesnot print anything on d console as i have printed the msgs , i want to save the selected file to d diskwat could b the problem?
File chooser is appearing..please help me

delete flag offensive retag edit

7 Replies

Sort by ยป oldest newest

answered 2011-09-07 07:08:26 +0800

bhushan2169 gravatar image bhushan2169
138

hello does anybody knw???

link publish delete flag offensive edit

answered 2011-09-07 07:46:53 +0800

RichardL gravatar image RichardL
768 4

Check out this thread: http://www.zkoss.org/forum/listComment/17228-Fileupload-get-1-is-returning-null

link publish delete flag offensive edit

answered 2011-09-07 07:51:57 +0800

bhushan2169 gravatar image bhushan2169
138

I tried that code but now it is giving error on media.getStreamData as
java.lang.NullPointerException "Attempt to invoke method getStreamData on null value"

why is it like this media is not null as it goes inside the if but media [ i ] is nulll

link publish delete flag offensive edit

answered 2011-09-07 20:04:06 +0800

samchuang gravatar image samchuang
4084 4

updated 2011-09-07 20:04:28 +0800

Hi

you could refer to Fileupload

link publish delete flag offensive edit

answered 2011-09-07 23:33:34 +0800

bhushan2169 gravatar image bhushan2169
138

hi samchuang,
I have used both the approaches but somehow the media is gettting the elements as media is not null but as soon as I try to access it i. e. media[0].getName it gets exception that "Attempt to invoke method getStreamData on null value" and I cant figure out what the problem is. And the document you shared I have read it but it does not help with my problem.

link publish delete flag offensive edit

answered 2011-09-08 07:55:21 +0800

bhushan2169 gravatar image bhushan2169
138

????

link publish delete flag offensive edit

answered 2011-09-08 20:22:27 +0800

samchuang gravatar image samchuang
4084 4

Hi

@bhushan2169, refer to http://books.zkoss.org/wiki/ZK_Component_Reference/Essential_Components/Fileupload

I tested the sample code above, it's working

link publish delete flag offensive edit
Your reply
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

RSS

Stats

Asked: 2011-09-06 01:26:06 +0800

Seen: 242 times

Last updated: Sep 08 '11

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