on 03-30-2006 7:23 AM
Hi,
I am using the File upload UI element to upload a file. Is it possible to get the File path information from the UI element?? If so, how?
Regards
Praveen
hI,
chk this link...
regards
prasy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Praveen
I guess this weblog might help you
/people/rekha.malavathu2/blog/2006/12/12/handling-fileupload-and-filedownload-in-netweaver-developer-studionwds-2004s
Regards
Rahul
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Praveen,
When you upload file through fileupoad UI element all the information and data of the file get stored in your context .
Here are the steps:
1.Create a node <NameOfNode> with cardinality 1:n and an attribute <NameOfAttribute> of type "com.sap.ide.webdynpro.uielementdefinitions.Resource"
2.IPrivate<View_Name>.I<NameOfNode>Element element = wdContext.current<NameOfNode>Element();
Regards,
Rajeev
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Praveen,
Simple answer: this is not possible. It is even can be considered as security vulnerability if server knows path of file on client machine. IE (not all versions) sends this path, Mozilla/Firefox does not.
Btw, why you need path of file on client machine? Probably you are solving wrong problem
VS
Hi,
I require the file system path because I am calling a BAPI to checkin the document into SAP R/3. The BAPI expects a file system path as input and not a server path.
I assume there is no security issue here. If the application is alowing you to browse the client machine file system to upload a particular file then what's wrong in getting the file system path of that file?
Any workaround to get the path?
Regards
Praveen
Not quite, the application isn't allowing anything. All the application says is it needs a file and the browser (on the client!) has a widget that allows browsing the file system and select a file. When submitting the form, the browser includes the actual content of the file in the request together with the file name. But the browser doesn't tell the server where the file comes from (or at least it shouldn't). There's absolutely no reason the server side application should know the location of the file, and it shouldn't care either. All it needs is the file content and some metadata like the filename and the MIME type.
If your BAPI requires a system path, it likely needs this to know where the file should be stored "in R/3". That would be a path on the machine where R/3 is running, or more likely some path on your document server.
Kind regards,
Sigiswald
Hi,
Please go through the links below to get an idea in the FileUpload UI Element.
http://wiki.sdn.sap.com/wiki/display/WDJava/UploadingexcelfileusingWebDynproforJava
http://help.sap.com/saphelp_nw2004s/helpdata/en/42/fdf9c528d45171e10000000a1553f7/frameset.htm
Hi,
I am not getting the "IUploadFileElement" in the line
IPrivate<View_Name>.IUploadFileElement element = wdContext.currentUploadFileElement();
It lists IContextNode and IContextElement only and there is no IUploadFileElement.
Any idea?
- Praveen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Praveen,
Yes it will not come. Actully I have created a Node in the context of the view, named: <b>"UploadFile"</b>, and in that I have created a new attribute named <b>"FileName"</b>, of type: <b>com.sap.ide.webdynpro.uielementdefinitions.Resource</b>
Then only you will get the "IUploadFileElement" in the line.
I hope this will solve your problem.
Regards
Pravesh
PS: Please consider rewarding points if helpful.
Hi,
That solved the error in that line. Now I am getting a nullpointer exception because "element" is coming as null.
IPrivateFileBrowse.IUploadFileElement element = wdContext.currentUploadFileElement();
Here is the code:
public void onActioncomplete(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
String strPath = new String();
IPrivateFileBrowse.IUploadFileElement element = wdContext.currentUploadFileElement();
if (element != null) {
File file = new File(element.getFileName().getResourceName());
strPath = file.getPath();
}else {
strPath = "No path found: ";
}
wdThis.wdGetFileBroInterfaceController().complete(strPath);
}
- Praveen
Hi Praveen,
For the FileUpload UI you can get the file path information by this code.
IPrivate<View_Name>.IUploadFileElement element = wdContext.currentUploadFileElement();
InputStream text=null;
int temp=0;
try {
// If a file in the FileUpload field exists
// ----- Code to upload to the server -----
File file = new File(element.getFileName().getResourceName());
FileOutputStream out = new FileOutputStream(file);
// ----- End of code -----
if (element.getFileName() != null) {
text = element.getFileName().read(false);
// ----- Code to upload to the server -----
while((temp=text.read())!=-1)
{
out.write(temp);
}
// ----- End of code -----
}
out.flush();
out.close();
<b>// ------ To get the File Path -----------
String filePath = file.getPath();</b>}
catch (IOException e2)
{
e2.printStackTrace();
}
I hope this helps you.. For any further details kindly revert back.
Regards
Pravesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.