Click here to Skip to main content
11,806,350 members (64,700 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: SQLite Flex
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 20: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
0 Richard Deeming 205
1 Sergey Alexandrovich Kryukov 170
2 ppolymorphe 145
3 OriginalGriff 135
4 Abhinav S 120
0 OriginalGriff 3,330
1 Maciej Los 1,990
2 KrunalRohit 1,907
3 CPallini 1,905
4 Richard MacCutchan 1,227

Advertise | Privacy | Mobile
Web02 | 2.8.151002.1 | Last Updated 12 Apr 2012
Copyright © CodeProject, 1999-2015
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