File Input object

Questions related to using nuBuilder Forte.

File Input object

Postby miketee » Thu Dec 06, 2018 10:17 am

Hello folks,

I have a form with a File Input object on it. When I browse for and select a file, then save the record, the file is converted to JSON and saved in the table as expected. However, if i re-open this record, the File input shows "No file selected". There is no indication that a file has already been uploaded. Is there a way to show the filename here so I know what was uploaded?
Also, if I have two files with the same name, but in different folders, how can I know which version was uploaded (the JSON contains the filaname, but not the full path).

Cheers,
miketee
 
Posts: 9
Joined: Thu May 05, 2016 12:55 pm

Re: File Input object

Postby kev1n » Thu Dec 06, 2018 6:45 pm

Retrieve the file name of the file input object (e.g. fileupload) when saving the form and store it in a different field (e.g. filename)

Code: Select all
var f = $('#fileupload').prop('files');
if (f.length > 0) {
$('#filename').val(f[0].name).change();
}
If you like nuBuilder, please leave a review on SourceForge

nuBuilder Code Library (85)
Installation Guides
Updating nuBuilder

Join Discord to talk about nuBuilder!
kev1n
nuBuilder Team
 
Posts: 1198
Joined: Mon Oct 15, 2018 2:13 am

Re: File Input object

Postby miketee » Mon Dec 10, 2018 1:17 pm

Thanks Kevin,

Of course your suggestion will work, but I was surprised the functionality was not included in the File object itself. Every other input object on an edit form shows it's contents when you open the record, but not the File object (unless I am misusing it?). I can understand not showing the file contents themselves (particularly if it's a large file), but it would be helpful if the filename or better still the path could be shown to indicate the field is not empty.

Any comments Steven?

Cheers,
miketee
 
Posts: 9
Joined: Thu May 05, 2016 12:55 pm

Re: File Input object

Postby admin » Tue Dec 11, 2018 9:37 am

miketee,

The File Input object is an HTML, element. - that is the way it works.

kev1n's suggestion is a good one.


Steven
admin
Site Admin
 
Posts: 3405
Joined: Mon Jun 15, 2009 9:53 am


Return to General