Click here to Skip to main content
13,259,194 members (50,885 online)
Rate this:
Please Sign up or sign in to vote.
See more:
i m wondering to upload file from flex to sqlite database and again need to retrieve from database to flex.can anyone help me how to do this?
Posted 14-Mar-12 21:58pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

There are several good articles and tutorials to be found: try searching the easy way[^]

I also recommend to by a book, that topic will be covered in nearly all books.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

import flash.filesystem.File;
            import flash.system.Capabilities;
            import flash.utils.ByteArray;
import mx.utils.Base64Decoder;
            import mx.utils.Base64Encoder;
public var fnamearr:Array=new Array();
            private var loadedFile:ByteArray;
            public var byte:String;
            public var bytesarr:Array=new Array();
            public var p:int;
/*browse button function*/
public function browse_file(eve:MouseEvent):void{
                file1 = File.documentsDirectory;
                file1.addEventListener(Event.SELECT, handleSelectFile);
                file1.browseForOpen("Select Picture");
            public function handleSelectFile(event:Event):void
                if(os=="Win" ){
                    file_name.text =;
                else if(os=="Mac"|| os=="Lin"){
                    file_name.text =;
                var request:URLRequest = new URLRequest(file_name.text);
                var urlLoader:URLLoader = new URLLoader(request);
                urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
            private function onURLLoaderComplete(event:Event):void
                loadedFile =;
                var encoder:Base64Encoder=new Base64Encoder();
/*finally store bytesarr (array),fnamearr(filename array) into sqlite database*/

// save in sqlite database
public function saveLoadedFile():void
                for(var j:int=0;j<bytesarr.length;j++){
                    if(bytesarr[j].length!=0 && bytesarr[j]!='' ){
                        dbStatement=new SQLStatement();
                        dbStatement.text="INSERT INTO cmr_patient_files (patient_id,file,filename) VALUES (:recordId,:byteArray,:recordNote)";
                        dbStatement.parameters[":recordNote"] = fnamearr[j];
                        dbStatement.parameters[":byteArray"] = bytesarr[j];
                        dbStatement.parameters[":recordId"] = spat_id;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171114.1 | Last Updated 12 Apr 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100