cancel
Showing results for 
Search instead for 
Did you mean: 

Read file on local machine

Former Member
0 Kudos

Hai friends,

I have a scenario in which, have t read a file from local system not in the sever path say(
kpi
server0).

It is possible?. If it is, how to proceed?

can any one help me on this issue...

Regards,

Krish.

Accepted Solutions (1)

Accepted Solutions (1)

lokesh_kamana
Active Contributor
0 Kudos

Hi,

The only you can fullfill this sort of requirements is you have to upload the file into the server first and then read it from there .

Since when you are running the applications in the browser it only searches the path in the server not in the client system.

Thanks & regards,

Lokesh

Former Member
0 Kudos

Hi there,

Badly in need of a solution:

Is copying the concerned file to the server is the only solution?

What the user will do in case if the network access for the server is denied to him/her and client system is highly secured?

Is there any possibilities to read the file from the local/client machine?


sapsrv02\sapmnt\KPI\DVEBMGS02\j2ee\cluster\server0

This is my path where i can read the files.

Assume:


sapsrv02\sapmnt\KPI\DVEBMGS02\j2ee\cluster\server0\*Project_Files\log.txt*

It is not possible to read the log.txt file inside the Project_Files folder.

How to over come these difficulties???

Thanks,

RPN

Edited by: RPN on Dec 19, 2008 2:42 PM

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Krish,

answer to your questions-> If you are using web dynpro java application then you cannot read/write/share anything on client m/c with out using file upload UI as the application is deployed on server and which cannot recognise the client machine with out file upload UI.

If you are using a plain java application you can access the client files without file upload.

Hope this will help.

Regards

Narendra

Former Member
0 Kudos

Hi Krish,

u cannot directly specify the path and read the file directly using webdynpro application.

you have to use the file upload Ui element for reading the file and saing it to server.

for getting the file path you can use the below steps.

1. create a context like filePath of type com.sap.ide.webdynpro.uielementdefinitions.Resource

2. Assign the context to the file upload childs resource properties.

3.Now you can use the below code to fetch the url.

wdContext.currentContextElement().getFilePath().getUrl(0));

this will help you to retrieve file path. Now you can pass the above URl to read that file.

hope this will help.

Regards

Narendra

Former Member
0 Kudos

hi Narendra,

Thanks a lot ...

I tried your suggestion , i can read the file content by using the below code

filePath.read(false);

Somewhat my problem solved ...

One more requirement ...

Is it possible to read the file on the client system without using file upload ?

Is it possible to get the sharedocs path on the client system?

Is it possible to save the file on the client system?

Thanks & Regards,

Krish

Former Member
0 Kudos

hi Narendra,

Thanks a lot ...

I tried your suggestion , i can read the file content by using the below code

filePath.read(false);

Somewhat my problem solved ...

One more requirement ...

Is it possible to read the file on the client system without using file upload ?

Is it possible to get the sharedocs path on the client system?

Is it possible to save the file on the client system?

Thanks & Regards,

Krish

nikhil_bose
Active Contributor
0 Kudos

For reading file from local system, use [FileUpload UI element|http://help.sap.com/saphelp_nw04s/helpdata/en/42/fdf9c528d45171e10000000a1553f7/content.htm].

nikhil

Former Member
0 Kudos

Hi Nikhil,

I have a doubt in what you have suggested. Is it desirable to upload all the files that you want to read in an application, to the server?

Regards,

Anagha

Former Member
0 Kudos

Hai Nikil,

I had tried your suggestion and i can read a file, but that should be saved in server working directory. Then only it works. I cannot read the file directly from my system without saving in server.

Thanks and regards,

Krish

nikhil_bose
Active Contributor
0 Kudos

Hello Anagha/Krish,

Dynpro application running in a client browser can not directly access client machines file system. The only interface left in dynpro is FileUpload/Download UI elements as said earlier.

If it is in server system or in a network path which server can access, directly go for [java.io.File|http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html].

nikhiL

Former Member
0 Kudos

Hello Experts,

What is the solution if the network access is denied to the Server???

Please clarify my doubt...

Thanks,

RPN

Former Member
0 Kudos

Alright... thanks Nikhil.

So Krish, the only options you have are -

1. use fileupload and then read.

2. If you have a url you can read content from there

Regards,

Anagha

Former Member
0 Kudos

Hai Anagha,

The one way to read a file is by using File upload , i agree but what Krish asked is it possible to read a file which is not present in the Server.

Please provide a solution....

Thank You,

R.Jude Silvester.

Former Member
0 Kudos

Hi Krish,

Is your problem solved ?

You want to read a file from your machine and you want to save it on the server ....

Is that the problem you are facing.....? let me know ...

Regards,

Srini

Former Member
0 Kudos

hai Srinivas,

I want to read a file from my machine and want to save it on the server ..... It is possible ....?

I had done some examples on file upload ui control in nwds ... it reads the file only if that file exist on the server path....(say : - E:\usr
KPI\DVEBMGS02\j2ee\cluster\server0 path in server).

Still now i cant slove the problem can you help me.....

Thanks and regards,

Krish

Former Member
0 Kudos

What kind of file is it? Text, Excel..etc. ?

Have a look at blog:

Reading Excel Sheet from Java without using any Framework :

Also this thread:

Edited by: Anagha Jawalekar on Dec 19, 2008 1:58 PM

Former Member
0 Kudos

Hai Anagha,

Wanna to read a txt file in my system say (D:\test.txt)

Thanks and regards,

Krish