Announcement

Collapse
No announcement yet.

Save image into SQL Database

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • colc
    replied
    If you are using SQLITE then you can save images to a directory then call the image from there to insert into the app
    OR
    con
    vert the image to a CYPTO64 string using code like this :

    Code:
    local tbImg = Dialog.FileBrowse(true, "Locate File Picture", _DesktopFolder, "Pictures (.png, .jpg, .tif)|*.png;*.jpg;*.tif|", "", "dat", false, false);
    if tbImg and tbImg[1] ~= "CANCEL" then
    
        local ext=String.SplitPath(tbImg[1]).Extension;
        local newName= Input.GetText("Input_Model")..""..ext
        File.Copy(tbImg[1], _TempFolder.."\\"..newName, true, true, false, true, nil);
    
    
        error = Application.GetLastError();
        if (error ~= 0) then
        Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
        end
        local crypT64 = Crypto.Base64EncodeToString( _TempFolder.."\\"..newName, 0);--We convert the file into binary
        Input.SetText("Input_Picture",newName);
        Input.SetText("Input_Crypto64", crypT64);
        Image.Load("Load", _TempFolder.."\\"..newName);
        Image.SetVisible("Load", true);
    
    else
    --User Cancelled or did not select an image so we use default image
        local tbImg= _SourceFolder.."\\AutoPlay\\Images\\placeholder.jpg"
        local ext=String.SplitPath(tbImg).Extension;
        local newName= "Default"..ext
        File.Copy(tbImg, _TempFolder.."\\"..newName, true, true, false, true, nil);
    
    
        error = Application.GetLastError();
        if (error ~= 0) then
        Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
        end
        local crypT64 = Crypto.Base64EncodeToString( _TempFolder.."\\"..newName, 0);--We convert the file into binary
        Input.SetText("Input_Picture",newName);
        Input.SetText("Input_Crypto64", crypT64);
        Image.Load("Load", _TempFolder.."\\"..newName);
        Image.SetVisible("Load", true);
    
    end
    (PS : I sent you an example apz back in August??)

    If you are using SQLITE3 the do a search -
    here is an example by Ulrich https://forums.indigorose.com/forum/...ith-blob-field

    Cheers

    Leave a comment:


  • telco
    started a topic Save image into SQL Database

    Save image into SQL Database

    is anyone here have example how to save image into sql?
    i am using SQLite plugin for my database i found some furums using bloob? is it okay with sqlite? Perhaps very much appreciated if someone can share.

    Thank you
Working...
X