cancel
Showing results for 
Search instead for 
Did you mean: 

Validate a file exists

Former Member
0 Kudos

I am using the file upload control and I have searched these forums unsuccessfully for the answer to my question; How do you validate a given file path exists on the local machine?

i.e., if someone enters c:\my_file.txt how can I validate that there is in fact a my_file.txt in c:\?

ws_query is obsolete, open dataset is not working and we do not have the GUI function modules..

I don't even know if I am looking in the right place. Anyone know a quick solution to this?

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

You really can't. The browser has a sandbox security environement that keeps any application from directly interacting with the filesystem. The best you can do is to use the fileUpload UI element and check for the data attribute being empty. Here is a section from the online help:

Due to browser restrictions that are unrelated to Web Dynpro ABAP, the previously entered data path might disappear when a FileUpload UI element is clicked. In newer versions of the browser, it is therefore impossible to enter the file name in the entry field. The field always remains empty. The selection of the file name is therefore only possible in new browser versions using the Browse... button. You cannot enter the file name manually (using the keyboard or the Copy and Paste functions) or by setting the file name from the back end (directly or using context binding). For more details, read the security-related information in Internet Explorer 6 about handling <input type=file>.

For security reasons, the browser only accepts absolute paths or a path selection via the Browseu2026 button. If the path name is incorrect, the browser will not even forward the request.

http://help.sap.com/saphelp_nw70ehp1/helpdata/en/b3/be7941601b1d09e10000000a155106/frameset.htm

Former Member
0 Kudos

Thanks Thomas, I had come across that same documentation however I wasn't able to find concrete guidance regarding the valiation of the path.

I am just invalidating the file upload binding node after a successful file open to avoid any user confusion related to funky browser activity.

Answers (0)