Skip to Content
0
Nov 28, 2005 at 03:15 AM

FileUpload Problem

26 Views

Hi,

I tried the following code to Upload file using FileUpload Control

#The Context Elements used

->>FileUpload(Node)->data(attribute - binary)

->>FileUpload(Node)->file(attribute - string)

IPrivateTest1View.IFileUploadElement xfuelement=wdContext.createFileUploadElement();

wdContext.nodeFileUpload().bind(xfuelement);

IWDAttributeInfo dataInfo=wdContext.nodeFileUpload().getNodeInfo().getAttribute("data");

ISimpleTypeModifiable modinfo=dataInfo.getModifiableSimpleType();

IWDModifiableBinaryType bintype=(IWDModifiableBinaryType)modinfo;

String location = "c:
";

String file = wdContext.nodeFileUpload().currentFileUploadElement().getFilename();

bintype.setFileName(file);

bintype.setMimeType(WDWebResourceType.TXT);

String filename = location+file;

File destinationFile = new File(filename);

try

{

FileOutputStream out = new FileOutputStream(destinationFile);

out.write(wdContext.nodeFileUpload().currentFileUploadElement().getData());

}

catch(Exception e) { }

  1. When I Execute this i am getting an error in the explorer window

Error : BinaryAttribute AttributeInfo (Test1View.FileUpload.data) is null

File Upload is not happening

Can any one help.

Thanks in Advance