Upload a file to get its source path

1
0
-1

Hi. I try to get the path of a file that is on my computer. To do that, I want to use a File widget to browse in the explorer and find the file. Then I want to read the source path of this file. Any idea on how I can do this ? I try to look the methods of the "DocumentValue" class, but there is no "getPath" method.

1 answer

1
+1
-1
This one is the BEST answer!

I don't think this is actually possible, once you add the file to the widget it creates a copy of the file under tomcat which is the only reference you will get.

The originating location is essentially meaningless to the application.

To do what you want I think you will have to provide your own widget (java, javascript, jquery), add it to Application resources and then get the information, then write your own code to add the file to the DocumentValue.

I think we did this somewhere...but can't remember.

SCRUB ALL of the proceeding...

It's not possible. All browsers do not allow this for security reasons...except some old ones...

See here..., here.. etc.

regards Seán

Comments

Submitted by yannick.lombardi on Thu, 04/09/2015 - 14:13

Ok, thanks. I will add a Text Field where the user will manually paste the path of the file. Like this I'm sure that I can have the path on all browsers.

Submitted by Sean McP on Thu, 04/09/2015 - 14:15

But why would you need to keep this though? It means nothing to the process surely?

Out of interest only.

Submitted by yannick.lombardi on Thu, 04/09/2015 - 14:19

I don't want to copy the file in the process. All I need is the path of the file to read/modify it on later tasks.

Submitted by Sean McP on Thu, 04/09/2015 - 15:15

You will not be able to do this.

The whole idea of web services is that the browser/web will not have access to local files, only those in the web servers path.

We struggled with this I now remember, spent a long time figuring it out and found it was impossible.

Our process is now quite simple

User loads the file, we save it to either a webserver folder (under tomcat/Catalina) or to a database (in our case Postgres) then later in many other processes we access and edit the files as necessary...

No need for any client access at all, with all the necessary security benefits as well.

regards Seán

Submitted by yannick.lombardi on Thu, 04/09/2015 - 17:38

Thanks for your advices. I will change my process and upload the file on the server. I found in the documentation how to transform a DocumentValue into a File and now I can directly use it without accessing to the source file. I delete the copy at the end of the process.

Notifications