I am trying to retrieve the names of two attached files that a single item may contain in a list
I'm not sure how this function works, but here is what I have so far
var PicName1 = '';
var PicName2 = '';
for (var file in attachmentFiles) {
if (attachmentFiles.itemAt(i)) {
PicName1 = attachmentFiles.itemAt[i].get_name(0);
PicName2 = attachmentFiles.itemAt[i].get_name(1);
}
i++
}
I went out on a limb with get_name(0)
and get_name(1)
in hoping that it would find the name of the first and second file in that item. However, both of them return the name of the final attachment in the item (this is the same result as get_name()
).
The get_name()
function returns the following stared value in a URL that points to a list item
site.sharepoint.com/sites/mysite/Lists/ContactList/Attachments/1/**PhotoName1.jpg**
Is there a way I can extract the name of each file like this?