VL-Web V15: How to specifying the extension in the file picker

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
Rieko Saitoh
Posts: 52
Joined: Sat Apr 30, 2016 11:46 am

VL-Web V15: How to specifying the extension in the file picker

Post by Rieko Saitoh » Fri May 28, 2021 3:32 pm

Hi all,

I am creating an application that uploads a CSV file using a file picker.
In the file picker, the extension is displayed as "All files".
Is it possible to specify the extension ".csv"?
filepicker.png
filepicker.png (56.76 KiB) Viewed 570 times
Thank you.

Best regards,
Rieko Saitoh
LANSA japan

dominique
Posts: 41
Joined: Mon May 29, 2017 4:16 pm
Location: St. Gallen, Switzerland

Re: VL-Web V15: How to specifying the extension in the file picker

Post by dominique » Thu Jun 03, 2021 3:07 pm

Yes it's possible


Code: Select all

Define_Com Class(#PRIM_APPL.ICommonDialogFileOpen) Name(#openFileDlg) reference(*dynamic)
Define Field(#Result) Type(*BOOLEAN)
Define Field(#ResultFile) Type(*String)


#sys_appln.CreateFileOpenDialog Result(#openFileDlg)
#openFileDlg.AddFilter( '*.csv' '*.csv' )
#openFileDlg.InitialDir := *TEMP_DIR
....

#openFileDlg.Show Okpressed(#Result) Formowner(#Com_owner)
If (#Result)
#ResultFile := #openFileDlg.File
Endif

Rieko Saitoh
Posts: 52
Joined: Sat Apr 30, 2016 11:46 am

Re: VL-Web V15: How to specifying the extension in the file picker

Post by Rieko Saitoh » Fri Jun 04, 2021 12:58 pm

Hi dominique,

Thank you for your reply.
I would to do this in a VL-Web application, but the method "CreateFileOpenDialog" doesn't seem to work on the web.
The advice you gave is valid for desktop applications. I will use it as a reference.

Thank you for your support.

Best regards,
Rieko Saitoh
LANSA japan

dominique
Posts: 41
Joined: Mon May 29, 2017 4:16 pm
Location: St. Gallen, Switzerland

Re: VL-Web V15: How to specifying the extension in the file picker

Post by dominique » Tue Jun 08, 2021 2:09 pm

Hi Rieko

The web filepicker is easy to handle.
Have a look into xDemoWebUploadProgress for a Web Filepicker.

Code: Select all

Define_Com Class(#PRIM_WEB.FilePicker) Name(#FilePicker) Caption('Select a File To Upload') Displayposition(1) Ellipses(Word) Height(60) Left(8) Parent(#COM_OWNER) Tabposition(2) Tabstop(False) Top(8) Verticalalignment(Center) Width(969) Alignment(Center) Themedrawstyle('Heading1') Style(#Style1)
if you want to calculate the file size you can use something like this

Code: Select all

Mthroutine Name(CheckFile)
Define_Map For(*INPUT) Class(#PRIM_WEB.File) Name(#I_File File) Pass(*BY_REFERENCE)
Define_Map For(*Result) Class(#PRIM_ALPH) Name(#O_Result Result)

Define #iFileName *string
Define #iFileSize *string

#iFileName := #I_File.Name
#iFileSize := ("&1Kb").Substitute( (#I_File.FileSize / 1024).Round( Up 2 ).AsString )
#xDemoblob := #I_File.Blob


If ((#I_File.FileSize / 1024).Round( Up 2 ) > 6000)
#O_Result  := "file is too big"
Endif
#O_Result  := "Ok"
Endroutine

That sould help you.
Good luck

Regards
Dominique

Post Reply