Hi. I have a table with a file upload. I would like to retrieve the file name when the file is uploaded.
Question
Question
Replies
Hello, I haven't done uploods in a table, but on a normal upload, the filenames do show up in the variables.
The vars in the table rows can also be accessed as variables in a workflow and template. But you would have to probably have another step in your forms process to pass the name of the file into a field in a table row.
Hi Cris, if you would like to retrive the file name right after you upload it on the fill form page, you can refer to custom scripts in this post: https://answers.laserfiche.com/questions/144900/File-Upload-Name-Change
It need to be modified to work in table, here is an example:
$(document).ready(function () { function fileOnChange(event) { var filename = $(event.target).val().split('\\').pop(); $(event.target).closest('tr').find('.name-field input').val(filename); } $('.file-field input').on('change', fileOnChange); $('#q4 .cf-table-add-row').click(function() { $('.file-field input').off('change', fileOnChange); $('.file-field input').on('change', fileOnChange); }); })
#q4 is the table field id, and this part is needed if you want to handle newly added rows in table; file-field need to be added as classname to file upload field, and name-field need to be added as classname to the file name field.
Hello,
So happy to have found this post. I was able to duplicate this in Classic Forms Designer and get it to work for me (which was a big relief), however the form I need the functionality in is in the New Forms Designer. I do not seem to be able to get this to work in New Forms Designer.
I was able to use the q# in the Classic Designer, those are not present in the New Designer (at least not where I can see them). I have tried many variations of Field ID and Var ID in place of the q#. To no avail. Can anyone help provide an example of this solution customized for the New Designer, with screenshots?
Thanks in advance.
Christine
Hi Christine,
Such javascript code is not able to work with the new forms designer, I'd recommend you how to use the JS functions of the new designer from here