I need to upload picture from my RIA application to Mysql using java in server side.I use the following code in flex side.I use HTTPService to interact with java server ie Tomcat 5.5. # <?xml version="1.0" encoding="utf-8"?> # <mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" # layout="vertical" width="100%" height="100%" # title="Upload Files"> # # # <mx:Script> # <![CDATA[ # import mx.rpc.AsyncToken; # import mx.rpc.events.FaultEvent; # import mx.rpc.events.ResultEvent; # # public var refUploadFile:FileReference; # # private var UploadFiles:Array = new Array(); # # # // Called to add file(s) for upload # private function addFiles():void { # refUploadFile = new FileReference(); # refUploadFile.browse(); # # refUploadFile.addEventListener(Event.SELECT,onFileSelect); # refUploadFile.addEventListener(Event.COMPLETE,onFileComplete); # } # # // Called when a file is selected # private function onFileSelect(event:Event):void { # UploadFiles.push({ name:refUploadFile.name, # size:formatFileSize(refUploadFile.size), # status:"initial"}); # listFiles.dataProvider = UploadFiles; # listFiles.selectedIndex = UploadFiles.length - 1; # # //refUploadFile.load(); # for ( var i:int = 0 ; i < UploadFiles.length ; i+ + ) { # if( UploadFiles[i].name == refUploadFile ) { # UploadFiles[i].status = "loaded"; # listFiles.dataProvider = UploadFiles; # break; # } # } # } # # // Called to format number to file size # private function formatFileSize(numSize:Number):String { # var strReturn:String; # numSize = Number(numSize / 1000); # strReturn = String(numSize.toFixed(1) + " KB"); # if (numSize > 1000) { # numSize = numSize / 1000; # strReturn = String(numSize.toFixed(1) + " MB"); # if (numSize > 1000) { # numSize = numSize / 1000; # strReturn = String(numSize.toFixed(1) + " GB"); # } # } # return strReturn; # } # # # # private function onFileComplete(event:Event):void # { # refUploadFile = event.currentTarget as FileReference; # //var data:ByteArray = refUploadFile.data; # var data:ByteArray; # var loader:Loader = new Loader(); # loader.loadBytes(data); # # var token:AsyncToken = AsyncToken( # remoteUpload.doUpload(data, refUploadFile.name) # ); # # token.kind = refUploadFile.name; # # for ( var i:int = 0 ; i < UploadFiles.length ; i+ + ) { # if( UploadFiles[i].name == refUploadFile ) { # UploadFiles[i].status = "upload"; # listFiles.dataProvider = UploadFiles; # break; # } # } # } # # private function uploadResultHandler(event:ResultEvent):void # { # for ( var i:int = 0 ; i < UploadFiles.length ; i+ + ) { # if( UploadFiles[i].name == event.token.kind ) { # UploadFiles[i].status = "finished"; # listFiles.dataProvider = UploadFiles; # break; # } # } # } # # private function faultResultHandler(event:FaultEvent):void # { # for ( var i:int = 0 ; i < UploadFiles.length ; i+ + ) { # if( UploadFiles[i].name == event.token.kind ) { # UploadFiles[i].status = "error"; # listFiles.dataProvider = UploadFiles; # break; # } # } # } # # # ]]> # </mx:Script> # # <mx:HTTPService id="remoteUpload" destination="http://localhost: 8080/MyProj/Upload.jsp" # result="uploadResultHandler(event)" # fault="faultResultHandler(event)"/> # # # <mx:Canvas width="100%" height="100%"> # <mx:DataGrid id="listFiles" left="0" top="0" bottom="0" right="0" # allowMultipleSelection="true" verticalScrollPolicy="on" # draggableColumns="false" resizableColumns="false" sortableColumns="false"> # <mx:columns> # <mx:DataGridColumn headerText="File" width="150" dataField="name" wordWrap="true"/> # <mx:DataGridColumn headerText="Size" width="50" dataField="size" textAlign="right"/> # <mx:DataGridColumn headerText="Status" width="50" dataField="status" textAlign="right"/> # </mx:columns> # </mx:DataGrid> # </mx:Canvas> # <mx:ControlBar horizontalAlign="center" verticalAlign="middle"> # <mx:Button id="btnAdd" toolTip="Add file(s)" click="addFiles()" # label="Upload Files" width="150"/> # </mx:ControlBar> # # # </mx:Panel>
I want to know how the byte data send from flex can be retrieved as a byte array in java code? Thanks in Advance -- You received this message because you are subscribed to the Google Groups "Flex India Community" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/flex_india?hl=en.

