I have applied the code related to Uploading a File on a Subform from the 4.5 Code Library https://github.com/nuBuilder/nuBuilder- ... /README.md.
Everything works, the file uploads and the file name gets underlined and can be downloaded. The download link breaks and the underlining disappears as soon as the record on the Browse and Edit Form is saved. (see before and after saved pics). I applied the code as is and do not have any PHP Custom Code on BS or AS.
How can I restore the downloading capabilities or possibly add an Input button to allow the download of the pdf file?
These are the functions related to the pdf downloading
Code: Select all
function createDownloadLink(field, folder, fileId, fileName) {
$('#' + field)
.css({
"text-decoration": "underline"
})
.css('cursor', 'pointer')
.off('click')
.attr({
fileName: fileName,
fileId: fileId,
folder: folder
})
.attr('readonly', 'readonly')
.click(function(event) {
downloadFile($(this).attr('folder') + $(this).attr('fileid') + '_' + $(this).attr('fileName'), $(this).attr('fileName'));
});
}
function addDownloadLinks(subform) {
var sf = nuSubformObject(subform);
var cName = sf.fields.indexOf(idFileName);
var cId = sf.fields.indexOf(idFileId);
for (var i = 0; i < sf.rows.length; i++) {
var fileId = sf.rows[i][cId];
var fileName = sf.rows[i][cName];
if (fileName !== '') {
createDownloadLink(idSubForm + nuPad3(i) + idFileName, uploadFolder, fileId, fileName);
}
}
}
function downloadFile(url, filename) {
var a = document.createElement("a");
a.href = url;
a.setAttribute("download", filename);
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}
if(nuFormType() == 'edit') {
addDownloadLinks(idSubForm);
} else
{
if (typeof nuStopBrowserResize == 'function') {
nuStopBrowserResize();
}
}
Thanks for any help you can provide.