function GetDisplayName(path) { var i; if ( (i = path.lastIndexOf("\\")) != -1 || (i = path.lastIndexOf("/")) != -1 ) { return i < path.length ? path.substring(i + 1) : ""; } return path; }
function BeginAttach() { var path = document.filesform.userFile.value; var displayName = GetDisplayName(path); self.opener.document.foo.attach1.value = displayName; self.opener.document.foo.submit(); self.close(); }
<input type="hidden" name="attach1" value=""> <input type="hidden" name="attach2" value=""> etc..
<input type="file" name="userFile[]" size="20"> <input type="file" name="userFile[]" size="20"> etc..
self.opener.document.foo.attach1.value = 'FileName1'; self.opener.document.foo.attach1.value = 'FileName2';