Lotus Script, how to avoid duplicate file names of file upload attachments

5 pts.
Tags:
LotusScript
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

Answer Wiki

Thanks. We'll let you know when a new response is added.

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;
}

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following