B4J Question [BANanoVueMaterial] Recommended way to get the full path & file name from a VMFileInput component

ahabbass

Member
What is the recommended way to get the full path and file name from a VMFileInput component on a modal dialog and update a table field of a MySQL database?
Could I have an example?

Thanks in advance!
 

ahabbass

Member
As I read further, I think that it's not possible to have the full path (for security reasons). But what about the file name?
 
Upvote 0

Mashiane

Expert
Licensed User
Longtime User
The VMFileInput is just a wrapper for the normal <input type=file> HTML component and as such you cannot get the full path of the file, for security reasons.

in the modFileInput module, we have defined a file input as

B4X:
vm.CreateFileInput("fi1", Me).SetMultiple(True).SetLabel("File input").SetVModel("myfiles").SetPlaceholder("Please choose some files").AddToContainer(cont, 1, 1)


You can however get the file name using the VModel. To get a vmodel value, use

B4X:
Dim fName as string = vm.getdata("myfiles")

There is also a _change event that exists in the examples. I have updated it to give one some file properties like size, date etc.

Each file object is defined as:

B4X:
Type FileObject(FileName As String, FileDate As String, FileSize As Long, FileType As String)

B4X:
'file change
Sub fi1_change(fileList As List)
    Log("fi1_change")
    For Each obj As Object In fileList
        Dim fo As FileObject = BANanoShared.GetFileDetails(obj)
        Log(fo.FileName)
        Log(fo.FileDate)
        Log(fo.FileSize)
        Log(fo.FileType)
    Next
End Sub
 
Last edited:
Upvote 0
Top