I'm having an issue with adding attachements to a newly created SPList Item, the list item is created via a custom submission form built with ASP.NET and C#, I'm using the asp:fileupload control as follows:

<asp:FileUpload ID="AttachOne" runat="server" />
<asp:RequiredFieldValidator ID="rfvAttachOne" ControlToValidate="AttachOne" runat="server" ErrorMessage="*"/>

in the code behind I'm saving the attachment like this:

listItem.Attachments.Add(AttachOne.FileName, AttachOne.FileBytes);

The above code is working fine, but once the component got deployed to another environment, alot of items were submitted through the form without the attachments, even though the file upload control is required , also there were alot of items that are updated on the list along with their attachments.

For example if I have a list with more than 3000 items, there are like 400 items in the list that do not have attachments, and the rest 2600 items do have attachments.

Is there something I could look for to resolve this issue? Is there something wrong with the ASP file upload control that made it drop files on form submission?

Note: I'm restricting the file types that could be uploaded through a regular expression formula.

<asp:RegularExpressionValidator ID="revAttachOne" ControlToValidate="AttachOne" runat="server" ErrorMessage="message" ValidationExpression="^.*\.(pdf|PDF|jpg|JPG|png|PNG)$" SetFocusOnError="true"></asp:RegularExpressionValidator>

Any help is much appreciated!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.