SharePoint file upload / attachment control has a very big issue is " SharePoint List will not allow to attach duplicate files."
If we used custom file upload control we dont have direct way to restrict to upload duplicate files.
we will get the below error message.
"Fail to get the value of the attachments column. A file with same name is already exists".
We can handle this error by using JQuery.
Here we have only one option to replace the last uploaded control with new one.
The internal functionality of the file upload control is, when ever a file is uploaded, SharePoint will hide the existing upload control and will create new upload control to upload another file.
If we used custom file upload control we dont have direct way to restrict to upload duplicate files.
we will get the below error message.
"Fail to get the value of the attachments column. A file with same name is already exists".
We can handle this error by using JQuery.
// it is the same duplicate check code var foundDuplication = false; $('#idAttachmentsTable').find('tbody').find('tr').each(function () { var existingFileName = $(this).find('.ms-vb').find('a').text(); // if the existingFileName is empty then the attachment was uploaded in this session // that is, it is not saved yet if (existingFileName == '') { var existingFilePath = $(this).find('.ms-vb').find('span').text(); existingFileName = existingFilePath.replace(/^.*[\\\/]/, ''); } if (newFileName == existingFileName) { foundDuplication = true; return false; } }); if (foundDuplication) { alert("A file with name '" + newFileName + "' is already attached to this item."); // $('#attachmentsOnClient').find('input').last().clone(true).remove(); //$('#attachmentsOnClient').find('input').last().val(''); var lastupp = $('#attachmentsOnClient').find('input').last(); //$('#attachmentsOnClient').find('input').last().replaceWith(($('#attachmentsOnClient').find('input').last()).clone(true)); lastupp.replaceWith((lastupp).clone(true)); document.getElementById("onetidIOComment").value = ""; }
Step: 1
SharePoint Custom file attachment control
Step: 2
Client Validation for SharePoint file Upload Control
Step: 3
SharePoint add comments for each attached document
0 comments: