Hi Friends,
I have one doubt on File Upload functionality. All ready I have done that file upload code but here I am looking one problem. My Req is I have to upload only the u201CHX10STCKBL.xlsu201D if client will change the file name the excel file is not upload.
Means I need Validation if client upload u201CHX10STCKBL.xlsu201D it is upload or can change Excel File name that time it is not uploaded.
I have to done this code for File upload.
InputStream text = null;
int temp = 0;
try
{
File file = new File(wdContext.currentContextElement().getResource().getResourceName().toString());
wdComponentAPI.getMessageManager().reportSuccess("filePath Vijay123:::"+file);
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();
path = file.getAbsolutePath();
wdComponentAPI.getMessageManager().reportSuccess(path);
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
Here file will saved Server Path.
Regards
Vijay Kalluri