How to get byteArray of file when uploading in Flex 2 -


     there wsdl have 1 method take bytearray & filename(which want write) parameter write file in local system, following code...  public void writelocation(byte[] bytetowrite, string filename) throws filenotfoundexception {     stringbuffer filelocation = new stringbuffer("d:\\products\\device");     filelocation.append("\\"+filename);     file file = new file(filelocation.tostring());     bufferedoutputstream bufferwriter = new bufferedoutputstream(new fileoutputstream(file));     try      {         bufferwriter.write(bytetowrite);     }     catch (ioexception e)      {         system.out.println("error file writing....");         e.printstacktrace();     }         {         try          {             bufferwriter.close();         }          catch (ioexception e)          {             e.printstacktrace();         }     } } 

now using flex 2 & following :

<mx:application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:webservice id = "bytecheckupload" wsdl="http://localhost:8080/xfiretest/xfire/employeeservice?wsdl" showbusycursor="true">         <mx:operation name="writelocation" fault="writelocationfh(event)" result="writelocationrh()"/>     <mx:webservice/> <mx:script>     <![cdata[         import mx.controls.alert;         import mx.rpc.events.faultevent;          private var refuploadfile : filereference;          public function uploadfile() : void         {             refuploadfile = new  filereference();              refuploadfile.browse();              refuploadfile.addeventlistener(event.select,onfileselect);              refuploadfile.addeventlistener(event.complete,onfilecomplete);           }          public function onfileselect(event : event) : void         {             refuploadfile.load();         }          public function onfilecomplete(event : event) : void         {             refuploadfile = event.currenttarget filereference;              var data:bytearray = new bytearray();              refuploadfile.data.readbytes(data,0,refuploadfile.data.length);               bytecheckupload.writelocation(data, refuploadfile.name)          }          public function writelocationfh(event : faultevent) : void         {             alert.show(event.fault.faultstring);             }          public function writelocationrh() : void         {             alert.show("please check location .... !!!");         }     ]]> </mx:script> <mx:button x="308" y="156" label="click button upload file" click="uploadfile();"/> 

but flex 2 showing error when searched found out in flex 2 there no "data" property. unable create selected object bytearray.. can 1 me how that.. & don't want use httpservice (post method)..

please help.. in advance

that feature not available in fp 9. need target application flash player 10.

this intended flex 3 however, may or may not work older versions of framework. either way, issue using feature not available in version you're using.


Comments

Popular posts from this blog

how to build hyperlink for query string in php -

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

html - How to set table cell value using jquery -