B4J Question File chooser for image pick

microbox

Active Member
Licensed User
Longtime User
I'm trying to construct code that will use file chooser to open an image file (jpg) in preparation to save it to Mysql database as blob file. The code I'm experimenting is a copy and paste from different thread.
B4X:
Sub btnfd_MouseClicked (EventData As MouseEvent)
    Dim f As String = fc.ShowOpen(MainForm)
    If f <> "" Then
        TextArea1.Text = File.ReadString(f, "")
    End If
  
    For Each row() As Object In result.Rows
    Dim out As OutputStream = File.OpenInput("C:\AB4JProjects","caption.jpg")
    Dim In As InputStream
    Dim Buffer() As Byte
    Buffer = row(0) ' gives error here, says that can not convert a string to byte array
    In.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
    File.Copy2(In, out)
    out.Close
End Sub

1. I don't really understand, how result.rows be used here?
2. How can I replace File.OpenInput("C:\AB4JProjects","caption.png") after I select using File chooser?

I appreciate any input and thanks for time.
 

microbox

Active Member
Licensed User
Longtime User
Wow...got it working! :D
doneIt.png
 
Upvote 0

microbox

Active Member
Licensed User
Longtime User
Thanks Enrique...I appreciated the time helping. Time for me continue what I left doing on my mini app ...yeah time to rest and enjoy my coffee.:)
 
Upvote 0
Top