Skip to Content
author's profile photo Former Member
Former Member

How to Save a file uploaded in WebDynpro Java to Windows server

Hi Guys,

I need to save a file uploaded in WebDynpro Java to a location on one of my companys many internal Window servers but I cannot get it to work. I do not get any errors with the following code, but NOTHING happens... And when I check the folder it is still emply... Please advise. I am particularly not sure about specifying the Path syntax. Also, I do have permission to write to this server. Is it even possible to save to a Windows server from WebDynpro??

//uploaded document already in context...

byte[] file = element.getFileResource();

// get the size of the uploaded file



// get the extension of the uploaded file


String fName = wdContext.currentContextElement().getFName();

String fExt = wdContext.currentContextElement().getFileExtension();

String foName1 = "
HRP_Attachments\" + fName + ".pdf";

File f1 = new File(foName1);

DataOutputStream dos1;

dos1 = new DataOutputStream(new FileOutputStream(f1));




Edited by: christiaanp on Sep 30, 2011 8:07 AM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Sep 30, 2011 at 08:18 AM

    Hi Christiaan,

    When specifying the path, make sure you escape the slashes

    So, when you would normally use something like


    in your code you must use it in the form:

    String fileName = "\\\\server\\path\\file.txt";

    Hope this helps!

    Robin van het Hof

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi,

      In retrospect, it's better to use it in following form btw:

      String filename = File.seperator + File.seperator + "server" + File.seperator + "path"+ File.seperator + "filename.txt";

      to be platform independent, but then I don't think it would solve your issue...

      Can you check permissions? The service user under which the NetWeaver application runs (so not the logged in NW user) should have permissions to write to your destination

  • Posted on Sep 30, 2011 at 11:05 AM

    the file object cannot handle your case

    i would suggest you setup ftp server in target server and upload the file using ftp java api, you can use some open source solution.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.