Friday, July 28, 2006 - Limit file types in list item attachments
To place file type restrictions on list attachments on a per list basis you need to add the OkAttach function from ows.js to the new item and edit item aspx pages for the list in question.
function OkAttach()
{
fileID = FileuploadString + FileUploadIndex;
fileInput = attachmentsOnClient.all(fileID);
filename = TrimWhiteSpaces(fileInput.value);
if (!filename)
{
var L_FileNameRequired_TXT = "You must specify a non-blank value for File Name.";
alert(L_FileNameRequired_TXT);
fileInput.focus();
}
else
{
var L_FileUploadToolTip_text = "Name";
oRow = idAttachmentsTable.insertRow();
RowID = 'attachRow' + FileUploadIndex;
oRow.id = RowID;
oCellFileName = oRow.insertCell();
oCellFileName.className = "ms-vb";
oCellFileName.innerHTML = filename + " ";
oCellControl = oRow.insertCell();
oCellControl.className = "ms-propertysheet";
oCellControl.innerHTML = "<.IMG SRC='" + document.all.RectGifUrl.value +
"'> <.a tabindex=1 href='javascript:RemoveLocal(" + RowID + ",\"" + fileID +
"\")'>" + L_Delete_Text + "<./a>";
fileInput.style.display="none";
++FileUploadIndex;
attachmentsOnClient.insertAdjacentHTML("beforeEnd",
"<.input tabIndex=1 type=file class=ms-long name=" +
FileuploadString + FileUploadIndex +
" title=" + L_FileUploadToolTip_text +">");
var theForm = fileInput.form;
theForm.encoding = 'multipart/form-data';
idAttachmentsRow.style.display='block';
ShowPart1();
}
}
Make sure you place the function inside the openning FORM tags and write your restriction code in the top of the ELSE block.
|
|
|
|
About Dan's Blog
The blog of Dan Iveson.
This will contain a mixture of technical articles related to Windows Sharepoint Services, Sharepoint Portal Server, other programming and family stuff.
« July 2010 »
| Mon | Tue | Wed | Thu | Fri | Sat | Sun |
| | 1 | 2 | 3 | 4 |
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 | 31 | |
Friends
|