cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with FileUpload control

Former Member
0 Kudos

Hi ,

I am facing a problem while using FileUpload control. It is as follows :

FileUpload control has two properties :

1. FileName

2. FileData

When using the browse button I select a file the contents of upload control include the absolute path to the file (eg, C:\Documents and Settings\i032874\Desktop\Test.rtf ). But when I access the FileName what I get is only the file name Test.rtf.

Now my idea is that directly accesing the upload control element may give me the complete path to the file.

Please do let me know if there are any other options.

Else please tell me how to access a WD UI Element directly (FIleUpload control in this case).

Regards,

Parminder

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Parminder,

It is not possible to get the PATH for browser security reasons.

I also have checked in debug that full path is available but getFileName() method retrieves only the file name and not absolute path.

See this link also as confirmation from our great VS.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Parminder,

When you have created the FileUpload UI element, you would have linked to a value attribute (say "X").

After the user selects the file (say "C:\Folder\Test.txt"), clicks on a button or does some action, in the method just read the context attribute value X.

I tried it, it is giving the full path.

In my case i had a value attribute "FN" directly under the CONTEXT. I linked "FN" to DATA property attribute of FileUpload UI element.

I had a button and FileUpload UI element in my view.

On Click of the button, i read the file name, it gave me full path.

onActionButtonClick(Event)
{
   String fileName = wdContext.currentContextElement.
                               getFN();

   // This fileName gave me full path
}

Thanks

Senthil

Former Member
0 Kudos

Hi Senthil,

The context attribute value gives me only the file name as I said. But I need the absolute path.

Context attribute does not give that.

Regards,

Parminder

Former Member
0 Kudos

Hi,

I have modified my answer, just see the answer again.

To test this.. i created a value attribute "FN" directly under the CONTEXT. I linked "FN" to DATA property attribute of FileUpload UI element.

I had a button and FileUpload UI element in my view.

On Click of the button, i read the file name, it gave me full path.

onActionButtonClick(Event)
{
   String fileName = wdContext.currentContextElement.
                               getFN();
 
   // This fileName gave me full path
}

Thanks

Senthil

<b>P.S: Reward Points for useful answer.</b>

Message was edited by: SenthilKumar Radhakrishnan

Former Member
0 Kudos

Hello Senthil,

Can you please tell me how to link the context node to data property attribute.

Regards,

Parminder

Former Member
0 Kudos

Hi,

1. Create a value attribute in your view context.

2. Go to corresponding View Layout, select the fileUpload UI element and go to DATA property attribute and select the value attribute (created in view context).

Quick Question, what you planned to do with the full path name or file name ?

Thanks

Senthil

P.S: Reward Points for useful answers.

Former Member
0 Kudos

Hi Parminder,

You can create a value attribute of type binary(or other type) in your view context.

open the layout and FileUpload UI element and you can see the property DATA.There you can bind the context that you just created.

Further you have to use this code in your doInit method

wdContext.getNodeInfo().getAttribute("your-addribute").getModifiableSimpleType();

then in your button action (to trigger the upload).

IWDAttributeInfo attriInfo =wdContext.getNodeInfo().getAttribute("your-attribute");

IWDModifiableBinaryType binaryType = (IWDModifiableBinaryType)attriInfo.getModifiableSimpleType();

String fileName = binaryType.getFileName();

Former Member
0 Kudos

Hi All,

Thanks for all the help. I have tried all the options you gave me but it does not give me the full path it just gives me the file name. I also contacted Web Dynpro team. They said it is not possible for security reasons. Same as Senthivel told.

Once again thanks for the help.

Regards,

Parminder

Former Member
0 Kudos

Hi,

But there is another problem here. I have a dropdown on this view with this FileUpload control. When I select a value in the DropDown the screen refreshes and the FileUpload control does not show the filename anymore although the context mapped to this control still has the file name.

How can I make it show the file name ?

Regards,

Parminder

Former Member
0 Kudos

Hi,

I am creating a component for file upload. In that Visible control file upload and tableview. If I selected file through the browse button in the fileupload UI and i am selecting the some value in table view when i am selecting in tableview the value in the browsed inputfelid get erased.

Is this possible to set the value for that inputfeild through scripts

or any other way to solve this problem?

i am having same kind of problem mentioned above. if u solved can u please guide me.i am developing as portal component.

Helpful answers will appreciable.

Thanks & Regards,

Kathiresan R