Page 1 of 1

File Input object

PostPosted: Thu Dec 06, 2018 10:17 am
by miketee
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,

Re: File Input object

PostPosted: Thu Dec 06, 2018 6:45 pm
by kev1n
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();
}

Re: File Input object

PostPosted: Mon Dec 10, 2018 1:17 pm
by miketee
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,

Re: File Input object

PostPosted: Tue Dec 11, 2018 9:37 am
by admin
miketee,

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

kev1n's suggestion is a good one.


Steven