Skip to Content
0
Former Member
Sep 30, 2011 at 06:04 AM

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

99 Views

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

element.setFileSize(this.getFileSize(file));

wdContext.currentContextElement().setFSize(this.getFSize(file));

// get the extension of the uploaded file

element.setFileExtension(binaryType.getMimeType().getFileExtension());

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

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

String foName1 = "
server01.w9\Files\P
HRP_Attachments\" + fName + ".pdf";

File f1 = new File(foName1);

DataOutputStream dos1;

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

dos1.write(file);

dos1.flush();

dos1.close();

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