5 pts.
 Lotus Script, how to avoid duplicate file names of file upload attachments
Hi, We have a problem in uploading files with the same names. Web application / Domino 7 We have a form with a file upload control and the user can select a image. Let say for example user selects the image ABC.GIF and submit by default it will get attached to the document. Now the user again edits the document and then attaches the file with the same name ABC.GIF, now what notes is doing is it renames the new ABC.GIF with some internal name. How can i find the exact name of the file been attached and how can i avoid the duplicate names. i tried using the embedobject of notes class property Source and Name but both returns only the internal name. I dont know how to avoid the duplication of names. Could any one help me. Ganapathy ganapathy_home@yahoo.com

Software/Hardware used:
ASKED: February 4, 2008  11:25 AM
UPDATED: February 5, 2008  7:13 PM

Answer Wiki:
Create a JavaScript variable in the HTML Head Content object: "var attNames = [" + @Implode(""" + @AttachmentNames + """; ",") + ">;" You can then use JavaScript validation to check the content of file-type fields against the array. Note that the client (browser) is the only place you can actually prevent uploading of duplicate filenames. The general outline of the validation would look like this: function validateUploads() { var elems = document.forms[0].elements; for (var i=0; i<elems.length; ++i) { if (elems[i].type && elems[i].type == "file") { var filepath = elems[i].value; if (filepath != "") { filepath = filepath.substring(filepath.lastIndexOf("/"), filepath.length); for (var j = 0; j < attNames.length; ++j) { if (filepath.toLowerCase() = attNames[j].toLowerCase()) { alert("A file named " + filepath + " has already been uploaded to this document."); elems[i].focus(); return false; } } } } } return true; }
Last Wiki Answer Submitted:  February 5, 2008  7:13 pm  by  StanRogers   150 pts.
All Answer Wiki Contributors:  StanRogers   150 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _