ZK - Open Source Ajax Java FrameworkZK - Open Source Ajax Java Framework

file upload

Mangapathi
19 Aug 2011 07:30:15 GMT
19 Aug 2011 07:30:15 GMT

Hi,

I want to get the selected file path value from file browse component in controller class. But when I tried to get the value of the component it is returning always null.

Tag I used in zul file is below.

<h:input id="filePath" type="file" size="40" />

Code I used to get the value in controller class is below. I specified value of the controller file in zul file.
//package impotred
org.zkoss.zhtml.Input package.

//declared variable
protected Input filePath;

String files = this.filePath.getValue();

Did I miss any thing ?
Any suggestions please...

thanks in advance.

jimmyshiau
31 Aug 2011 03:01:04 GMT
31 Aug 2011 03:01:04 GMT

Hi Mangapathi,
You have to listen onChange event

<zk xmlns:h="xhtml" xmlns:zk="http://www.zkoss.org/2005/zk">
	<window apply="org.zkoss.DemoWindowComposer">
		<h:input id="filePath" type="file" zk:onChange=""/>
		<h:input id="text" zk:onChange=""/>
		<button label="show" id="btn"/>
	</window>
</zk>

Due to the security issue, you cannot retrieve the full path, please refer to the following link
http://www.w3schools.com/jsref/prop_fileupload_value.asp