cancel
Showing results for 
Search instead for 
Did you mean: 

how to upload a file into specified location

Former Member
0 Kudos

Hi Frndz..

How to upload a file using File upload feature in web dynpro into our specified location(usr/sap/Images/....),not into workspace r default path in server.

Thanks in Advance

Regards

Rajesh

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Rajesh,

Use below code on your "Upload" Action:



	try
	{
// Give full path of folder on server where you want to upload the file. 

		File file = new File("D:\\usr\\sap\\Images\\"+wdContext.currentContextElement().getResource().getResourceName().toString());

// D:\usr\sap\Images folder should present on server
		FileOutputStream op = new FileOutputStream(file);
		
		if(wdContext.currentContextElement().getResource()!=null)
		{
			text=wdContext.currentContextElement().getResource().read(false);
				while((temp=text.read())!=-1)
				{
					op.write(temp); 
				}
		}
		op.flush();
		
		op.close();
		
	}

	catch(Exception e)
	{
		wdComponentAPI.getMessageManager().reportSuccess("Error while uploading file : "+e.getMessage());
	}


Thanks

Sandy

Answers (2)

Answers (2)

Former Member
0 Kudos
Former Member
0 Kudos

Hi Raj,

Please go through this help and explined here step by step on how to Uploading and Downloading Files in Web Dynpro Java for specific location.

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/00062266-3aa9-2910-d485-f1088c3a...

Thanks

Krishna