-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I am trying to attach a file from local system. It is working fine but wrong path is showing, when never I am trying to get the attached file's path.
zul file code :
<button id="b_upload" mold="trendy" upload="true" label="Browse" onUpload="@command('onFileUpload')"/>
ViewModel class code :
@Command("onFileUpload")
public void onFileUpload(@ContextParam(ContextType.BIND_CONTEXT) BindContext ctx) throws IOException {
UploadEvent upEvent = null;
...
upEvent = (UploadEvent) objUploadEvent;
if (upEvent != null) {
Media mediaObj = upEvent.getMedia();
File fileObj = new File(mediaObj.getName());
String canonicalPath = fileObj.getCanonicalPath();
String absolutePath = fileObj.getAbsolutePath();
System.out.println("CanonicalPath----->>"+canonicalPath);
System.out.println("AbsolutePath------>>"+absolutePath);
...
}
...
}
Example:-
Let, File is present in
C:\Users\Public\Pictures\Sample Pictures
then the out put of the above code is returning,
CanonicalPath----->>E:\Eclipse - Galileo\Penguins.jpg
AbsolutePath------>>E:\Eclipse - Galileo\Penguins.jpg
I want to save the attached file's path in the data base. but in this case I am unable to get the exact attached file path.
Is there any method to get the exact file path.
Thanks in Advance, Abhisek
Now browsers have a very high security so it preventing to show client local file system and for security it make sense for everyone ,no any internet user will like Server will know the our local file system if still any browser showing your file system in browser it is lake of security in the browser.
EDIT:-
For your reference you can read @BaluC answer in this link Stackoverflow Filte Path issue
I have one more query about this attachment browse file path.
The below sample code is returning the total path when I browse file in Windows IE 9.
<html>
<title>
Attachment
</title>
<body>
Path : <input type=file id="filePath" name="filePath">
</body>
</html>
But the same browser is not returning the total file path from ZK application.
Is this because of ZK limitation or ZK security restriction or Browser security restriction??
Thanks,
Subrat
Hi hswain,
As per you it is 'Browser security restriction' but as per the Subrat's sample html code is returning the full file path in IE9 but zk sample code is not returning the full file path in same IE9.
If it is a 'Browser security restriction' then the behavior of browser should be same for both the application that may be developed in simple html or zk.
I think this is ZK security restriction!!!
Thanks,
Abhisek
Asked: 2013-07-04 13:35:03 +0800
Seen: 76 times
Last updated: Jul 11 '13