If you are having trouble with the File Upload field within the Web Forms for Marketers module, specifically the form submission fails with a generic error, check your Sitecore log file. If you see either of the following two exceptions, there is a solution! Read on.

First exception:

4624 11:31:12 WARN  Object reference not set to an instance of an object. Exception: System.NullReferenceException Message: Object reference not set to an instance of an object. Source: Sitecore.Forms.Custom at Sitecore.Form.UI.Adapters.FileUploadAdapter.AdaptResult(Object value) at Sitecore.Form.Core.Utility.FieldReflectionUtil.GetAdaptedResult(ID fieldID, Object value) at Sitecore.Form.Core.Controls.Data.AdaptedControlResult..ctor(ControlResult result, Boolean simpleAdapt) at Sitecore.Form.Core.Submit.SubmitActionManager.AdaptResult(IEnumerable`1 list, Boolean simpleAdapt) at Sitecore.Form.Core.Submit.SubmitActionManager.ExecuteSaving(ID formID, ControlResult[] list, ActionDefinition[] actions, Boolean simpleAdapt, ID sessionID) at Sitecore.Form.Core.FormDataHandler.ProcessData(SimpleForm form, ControlResult[] fields, ActionDefinition[] actions)

4624 11:31:12 WARN  Web Forms for Marketers: an exception: Object reference not set to an instance of an object. has occured while trying to execute an action. This is most likely happening because you have two server configuration (separated CD from CM) and master database removed as per the Scaling Guide. The error happens in case if you did not configure the remote WFM service as per section 2.11 “Multiple Sitecore Instances” within the reference doc:

Simply add the connection string to the web service and make sure that the following setting on CD instance(s) is set to "web". This setting is defined within /App_Config/Include/forms.config file.

<!-- Sets the name of the master database -->
<setting name="WFM.MasterDatabase" value="web"/>

Second exception:

2780 14:55:48 ERROR Could not save posted file: Desert.jpg Exception: System.InvalidOperationException Message: An instance of Sitecore.Data.Items.Item was null. Additional information: Could not create media folder: 'D/Sitecores/WFFM 21/Website/sitecore/media library'. Source: Sitecore.Kernel    at Sitecore.Diagnostics.Assert.IsNotNull(Object value, Type type, String format, Object[] args)    at Sitecore.Resources.Media.MediaCreator.CreateFolder(String itemPath, MediaCreatorOptions options)    at Sitecore.Resources.Media.MediaCreator.CreateItem(String itemPath, String filePath, MediaCreatorOptions options)    at Sitecore.Resources.Media.MediaCreator.CreateFromStream(Stream stream, String filePath, Boolean setStreamIfEmpty, MediaCreatorOptions options)    at Sitecore.Resources.Media.MediaCreator.CreateFromStream(Stream stream, String filePath, MediaCreatorOptions options)    at Sitecore.Form.Core.Media.MediaUploaderEx.UploadToDatabase(ICollection`1 list)    at Sitecore.Form.Core.Media.MediaUploaderEx.Upload()    at Sitecore.Form.Core.Pipelines.FormUploadFile.Save.Process(FormUploadFileArgs args)

2780 14:55:48 WARN  An instance of Sitecore.Data.Items.Item was null. Additional information: Could not create media folder: 'D/Sitecores/WFFM 21/Website/sitecore/media library'. Exception: System.InvalidOperationException Message: An instance of Sitecore.Data.Items.Item was null. Additional information: Could not create media folder: 'D/Sitecores/WFFM 21/Website/sitecore/media library'. Source: Sitecore.Kernel    at Sitecore.Diagnostics.Assert.IsNotNull(Object value, Type type, String format, Object[] args)    at Sitecore.Resources.Media.MediaCreator.CreateFolder(String itemPath, MediaCreatorOptions options)    at Sitecore.Resources.Media.MediaCreator.CreateItem(String itemPath, String filePath, MediaCreatorOptions options)    at Sitecore.Resources.Media.MediaCreator.CreateFromStream(Stream stream, String filePath, Boolean setStreamIfEmpty, MediaCreatorOptions options)    at Sitecore.Resources.Media.MediaCreator.CreateFromStream(Stream stream, String filePath, MediaCreatorOptions options)    at Sitecore.Form.Core.Media.MediaUploaderEx.UploadToDatabase(ICollection1 list) &#xA0;&#xA0; at Sitecore.Form.Core.Media.MediaUploaderEx.Upload() &#xA0;&#xA0; at Sitecore.Form.Core.Pipelines.FormUploadFile.Save.Process(FormUploadFileArgs args) &#xA0;&#xA0; at (Object , Object[] ) &#xA0;&#xA0; at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) &#xA0;&#xA0; at Sitecore.Form.UI.Adapters.FileUploadAdapter.AdaptResult(Object value) &#xA0;&#xA0; at Sitecore.Form.Core.Utility.FieldReflectionUtil.GetAdaptedResult(ID fieldID, Object value) &#xA0;&#xA0; at Sitecore.Form.Core.Controls.Data.AdaptedControlResult..ctor(ControlResult result, Boolean simpleAdapt) &#xA0;&#xA0; at Sitecore.Form.Core.Submit.SubmitActionManager.AdaptResult(IEnumerable1 list, Boolean simpleAdapt)    at Sitecore.Form.Core.Submit.SubmitActionManager.ExecuteSaving(ID formID, ControlResult[] list, ActionDefinition[] actions, Boolean simpleAdapt, ID sessionID)    at Sitecore.Form.Core.FormDataHandler.ProcessData(SimpleForm form, ControlResult[] fields, ActionDefinition[] actions)

2780 14:55:48 WARN  Web Forms for Marketers: an exception: An instance of Sitecore.Data.Items.Item was null. Additional information: Could not create media folder: 'D/Sitecores/WFFM 21/Website/sitecore/media library'. has occured while trying to execute an action.

This error may happen if: