0

How to get the absolute path of attached file

asked 2013-07-04 13:35:03 +0800

abhisekpanda86 gravatar image abhisekpanda86 flag of India
5 2

updated 2013-07-04 13:51:38 +0800

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

delete flag offensive retag edit

3 Answers

Sort by ยป oldest newest most voted
1

answered 2013-07-04 14:11:53 +0800

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

updated 2013-07-05 09:40:29 +0800

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

link publish delete flag offensive edit
0

answered 2013-07-05 07:13:49 +0800

Subrat gravatar image Subrat flag of India
1

updated 2013-07-05 07:20:44 +0800

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

link publish delete flag offensive edit

Comments

See edited answer

sjoshi ( 2013-07-05 09:40:44 +0800 )edit

Browser security restriction

hswain ( 2013-07-05 09:42:58 +0800 )edit

Thanks for the quick response.

Subrat ( 2013-07-05 11:04:48 +0800 )edit
0

answered 2013-07-11 05:38:29 +0800

abhisekpanda86 gravatar image abhisekpanda86 flag of India
5 2

updated 2013-07-11 05:41:25 +0800

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

link publish delete flag offensive edit

Comments

No If any browser giving you path then it mean browser have security flaws there is no meaning to access client drive by server machine.

sjoshi ( 2013-07-11 06:20:27 +0800 )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
2 followers

RSS

Stats

Asked: 2013-07-04 13:35:03 +0800

Seen: 76 times

Last updated: Jul 11 '13

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