I'm facing a very bizzare error in SharePoint. Basically, when I upload a file to SharePoint using a custom form and a normal attachments field control:
<SharePoint:AttachmentsField runat="server" ID="fieldAttach" ControlMode="Display" FieldName="Attachments"></SharePoint:AttachmentsField>
After uploading the file, SharePoint is removing the last byte! Does anyone have any idea what may be causing the issue? We do not even have an event reciever or any other magic on this form.
This is causing the file to become corrupt. It's happening with all XPS documents (haven't check if it happens with other files yet).
Edit: It's happening with other files too.
I'm going to post the codebehind but I don't think it will be of much help. I'll try to isolate the problem sometime tomorrow.
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (Page.IsValid && SPUtility.ValidateFormDigest())
{
try
{
if (!ddEstimatedPaymentDate.IsDateEmpty)
{
PurchaseRequisition.EstimatedPaymentDate = ddEstimatedPaymentDate.SelectedDate;
}
else
{
PurchaseRequisition.EstimatedPaymentDate = null;
}
if (!ddDeliveryRequired.IsDateEmpty)
{
PurchaseRequisition.DeliveryRequiredBy = ddDeliveryRequired.SelectedDate;
}
else
{
PurchaseRequisition.DeliveryRequiredBy = null;
}
PurchaseRequisition.TotalAmount = Convert.ToDouble(txtTotalAmount.Text);
if (!string.IsNullOrEmpty(txtDepositRequired.Text))
{
PurchaseRequisition.DepositRequired = Convert.ToDouble(txtDepositRequired.Text);
}
else
{
#warning Since Deposit required has been identified to be nullable, nullable property may be implemented in the future
PurchaseRequisition.DepositRequired = 0;
}
PurchaseRequisition.PurposeOfPurchase = txtPurposeOfPurchase.Text;
PurchaseRequisition.NewAttachments = Page.Request.Files;
//extra validation before sending the purchase requisition for save.
if (PurchaseRequisition.ValidatePurchaseRequisition())
{
HideServerSideErrorMessages(ref txtServerSideErrors);
PurchaseRequisition.Update(false);
bool redirection = SPUtility.Redirect(CurrentList.RootFolder.ServerRelativeUrl, SPRedirectFlags.Default | SPRedirectFlags.DoNotEndResponse, HttpContext.Current);
}
else
{
DisplayServerSideErrorMessages(PurchaseRequisition, ref txtServerSideErrors);
}
}
catch (Exception exception)
{
...
}
}
}
HTML:
Attachments