cancel
Showing results for 
Search instead for 
Did you mean: 

Need Clarification in FileUpload...

Former Member
0 Kudos

Hi experts,

My Requirement is:

While clicking File UpLoad Browse button it should take me to the file loction of my desire by default.

Say: I have created a folder with the name of the user in the Server. When i access from the client machine, on click of the browse button the file upload dialog box should locate the user named folder in the server by default.

Please forward your suggestion.

Thanks,

RPN

Edited by: RPN on Dec 12, 2008 2:46 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

RPN,

Your requirement is to upload files to a particular server directory that you have created..

IWDUpload UI element get you the Resource and while writing it to the server, specify the path to it.



String path = "D:\\Test\\";

byte[] bytes = new byte[ 1024];

FileOutputStream out = new FileOutputStream( new File( path));
InputStream in = resource.read( true);
int len;
while( ( len = in.read( bytes)) > 0)
{
	out.write( bytes, 0, len);
}
in.close();
out.close();

vinod

Answers (3)

Answers (3)

Former Member
0 Kudos
Former Member
0 Kudos

Hi,

Say: I have created a folder with the name of the user in the Server. When i access from my local machine, on click of the browse button the file upload dialog box should locate the user named folder in the server by default.

I dont think this will work. especially pointing to the folder in server(How will the client browser no the shared folder of server?)

Regards

Ayyapparaj

Former Member
0 Kudos

Is there any possibility through hard coding.....?

Thanks,

RPN

former_member192434
Active Contributor
0 Kudos

you can do it both way by hard coding as well as dynamcially(I mean useing dyanamic coding),

Former Member
0 Kudos

Can you please provide some detailed information regarding that.....?

Thanks,

RPN

former_member192434
Active Contributor
0 Kudos

Hi

Check this pdf for creating folder dynamically

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/607e9392-8167-2b10-b9a8-e0aa297e...

for hardcoding see this code

public void onActionUploadFile(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionUploadFile(ServerEvent)

String FileName = "temp";//wdContext.currentContextElement().getDirectory();

InputStream input = null;

int i=0;

FileIncreament();

try {

String directory =".
temp
webdynpro
web
local
yh1245_ftp"+

"
Components
com.yash.yh1245.Upload
"FileNamewdContext.currentContextElement().getCounter();

boolean sucsss = new File(directory).mkdir();

if(sucsss){

wdComponentAPI.getMessageManager().reportSuccess("Directory Created ");

File file = new File(directory"
"
wdContext.currentContextElement().getResourceURL().getResourceName().toString());

FileOutputStream fos = new FileOutputStream(file);

wdComponentAPI.getMessageManager().reportSuccess(file.getAbsolutePath());

FilePath = file.getAbsolutePath();

if(wdContext.currentContextElement().getResourceURL()!=null){

input = wdContext.currentContextElement().getResourceURL().read(false);

//wdComponentAPI.getMessageManager().reportSuccess("Resource is not null ");

while((i = input.read())!=-1){

fos.write(i);

}

}

fos.flush();

fos.close();

wdComponentAPI.getMessageManager().reportSuccess("File Uploaded on server directory ");

//wdComponentAPI.getMessageManager().reportSuccess("Created File Locaiton::"+file.getAbsolutePath());

//}

//Get the File Size

// IPrivateFTPUpload.IContextElement element = wdContext.currentContextElement();

// if (element.getResourceURL()!=null) {

// IWDResource resource = element.getResourceURL();

// element.getFileSize(this.getFileSize(resource));

// }

}

}catch(Exception e){

e.printStackTrace();

}

//@@end

}

thanks

Former Member
0 Kudos

Thanks Anup Bharti,

But my requirement is opening the File Upload dialog box with my desired location by default

Thanks,

RPN

Former Member
0 Kudos

Hi

Pls follow this link might helps This contains the complete creating a folder and also uploading the file

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/607e9392-8167-2b10-b9a8-e0aa297e...

Regards

Prasad.