File uploading is working fine in Local but error when I deploy in server.
The error message is

> 
> Server Error in '/' Application.
> Object reference not set to an instance of an object.
> Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
> 
> 
> 

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionHandlingConfigurationView.GetExceptionPolicyData(String policyName) +186
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyCustomFactory.GetConfiguration(String id, IConfigurationSource configurationSource) +102
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyCustomFactory.CreateObject(IBuilderContext context, String name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache) +94
Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy.PreBuildUp(IBuilderContext context) +325
Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context) +138

[BuildFailedException: The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl, UIExceptionPolicy]) failed: Object reference not set to an instance of an object. (Strategy type ConfiguredObjectStrategy, index 2)]
Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context) +498
Microsoft.Practices.ObjectBuilder2.Builder.BuildUp(IReadWriteLocator locator, ILifetimeContainer lifetime, IPolicyList policies, IStrategyChain strategies, Object buildKey, Object existing) +65
Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp(IReadWriteLocator locator, ILifetimeContainer lifetimeContainer, String id, IConfigurationSource configurationSource) +729
Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.LocatorNameTypeFactoryBase`1.Create(String name) +187
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.GetExceptionPolicy(Exception exception, String policyName, ExceptionPolicyFactory factory) +90

[ExceptionHandlingException: The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl, UIExceptionPolicy]) failed: Object reference not set to an instance of an object. (Strategy type ConfiguredObjectStrategy, index 2)]
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.GetExceptionPolicy(Exception exception, String policyName, ExceptionPolicyFactory factory) +494
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(Exception exceptionToHandle, String policyName, ExceptionPolicyFactory policyFactory) +75
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(Exception exceptionToHandle, String policyName) +255
MFBMS.Web.Focuspages.Videouploader.btnUploadDocument(Object sender, EventArgs e) in E:\PROJECT\DEVELOPMENT\WEBSITE\FOCUS-TUTORIAL\Focustutorial\MFBMS.Web\Focuspages\FileUploader.aspx.cs:185
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +11594496
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +274
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1964

)

Here is the code that I try

```
protected void btnUploadDocument(object sender, EventArgs e)
    {
        try
        {
            string PathToSave = "";
            string FolderLocation = "";
            string FileName = "";
            string PathToDB = "";
            string FileType = "";

            if (!DocumentFileUpload.HasFile)
            {
                DocumentFileUpload.Focus();
                lblUploadMsg.Visible = true;
                lblUploadMsg.Text = "Select File Name.";
                lblUploadMsg.Focus();
                lblUploadMsg.CssClass = "FailedAlert";
                return;
            }
            else
            {
                FileUploaderBO objBO = new FileUploaderBO();
                FileUploaderData objdata = new FileUploaderData();

                //****** FOR SAVING IMAGE TO DATABASE******//
                //int length = DocumentFileUpload.PostedFile.ContentLength;
                //byte[] imgbyte = new byte[length];
                //HttpPostedFile img = DocumentFileUpload.PostedFile;
                //img.InputStream.Read(imgbyte, 0, length);
                //objdata.ByteImage = imgbyte;
                //****** End FOR SAVING IMAGE TO DATABASE******//

                FileType = ddlFileType.SelectedItem.Text;
                FolderLocation = Server.MapPath(@"~/FileFolder/" + FileType + "/");
                if (!Directory.Exists(FolderLocation))
                {
                    Directory.CreateDirectory(FolderLocation);
                }
                PathToSave = Server.MapPath(@"~/FileFolder/" + FileType + "/");

                FileName = DocumentFileUpload.FileName;
                PathToDB = "~/FileFolder/" + FileType + "/" + FileName;
                PathToDB = "~/FileFolder/" + FileType + "/" + FileName;

                string fileCheck = PathToSave + FileName;
                string tempFileToCheck = "";
                if (System.IO.File.Exists(fileCheck))
                {
                    int counter = 2;
                    while (System.IO.File.Exists(fileCheck))
                    {
                        tempFileToCheck = counter.ToString() + FileName;
                        fileCheck = PathToSave + tempFileToCheck;
                        counter++;
                        FileName = tempFileToCheck;
                        lblUploadMsg.Text = "A file with the same name is already exist." + "<br/> your file was saved as" + FileName;
                        lblUploadMsg.Focus();
                        lblUploadMsg.CssClass = "FailedAlert";
                    }
                }
                else
                {
                    PathToSave += FileName;
                    DocumentFileUpload.SaveAs(PathToSave);
                }

                objdata.FileTypeID = Convert.ToInt32(ddlFileType.SelectedValue == "" ? "0" : ddlFileType.SelectedValue);
                objdata.FileTypeName = ddlFileType.SelectedItem.ToString();
                objdata.FileName = FileName;
                objdata.FilePath = PathToDB;
                objdata.FileTitle = txtTitle.Text == "" ? null : txtTitle.Text;
                objdata.FileDecription = txtDecription.Text == "" ? null : txtDecription.Text;

                List<FileUploaderData> DataList = new List<FileUploaderData>();
                DataList = objBO.UpdateUploadFile(objdata);
                if (DataList.Count > 0)
                {
                    if (DataList[0].SQLOutput == 1)
                    {
                        lblUploadMsg.Visible = true;
                        lblUploadMsg.Text = "Uploaded Successfully.";
                        lblUploadMsg.Focus();
                        lblUploadMsg.CssClass = "SuccessAlert";
                    }
                    else if (DataList[0].SQLOutput == 2)
                    {
                        lblUploadMsg.Visible = true;
                        lblUploadMsg.Text = "Uploaded Update Successfully.";
                        lblUploadMsg.Focus();
                        lblUploadMsg.CssClass = "SuccessAlert";
                    }
                }
                else
                {
                    lblUploadMsg.Focus();
                    lblUploadMsg.Visible = true;
                    lblUploadMsg.Text = "Not Uploaded due to system error.";
                    lblUploadMsg.CssClass = "FailedAlert";
                }
            }
        }
        catch (Exception ex)
        {
            HandlePolicyException.ExceptionHandler(HandlePolicyException.PolicyName.UIExceptionPolicy, ex, "1000001");
            LogManager.LogError(ex, EnumErrorSource.Web);
            MessageAlert_.ShowMessage(ex, "system", 0);
        }
    }

```