File Upload for Sitecore Forms

Version 1.1 of the Sitecore Forms Extensions add the File Upload Control to your forms toolbox!

It features 2 implementations for storing your files (file system or azure blob storage) and is easily extensible to add your own storageprovider.

The control also comes with 2 validators. One for the content type of the files and one for the maximum file size.

Storage Providers

After installation of the module (just a sitecore package to install), you will have to configure a FileUploadStorageProvider.

This storage provider will take the uploaded file and store it somewhere. Currently, we have to storage providers out of the box.

File System

<?xml version="1.0"?>
<configuration xmlns:patch=""  xmlns:role="">
      <fileUploadStorageProvider type="Feature.FormsExtensions.Business.FileUpload.FileSystemFileUploadStorageProvider, Feature.FormsExtensions">

For this provider, you have to configure 2 parameters:

  • rootStoragePath: the path on the local file system to store the file
  • fileDownloadUrlBase: this is the url to download the uploaded file afterwards, it should contain {0}, as the {0} will get replaced with the uploaded filename

Files are no stored under the original filename but they receive a random guid + the original extension.

Note that the module does not provide a method to download the files. It only constructs a download URL.

Beware that on load-balanced solutions, you will need to make sure that the storagePath is shared over the servers.

Azure Blob Storage

When using Azure, this is really my personal favourite option. The disk space is cheap, it is redundant, you don’t need to worry about scaled solutions, and the download functionality comes with the system.

<?xml version="1.0"?>
<configuration xmlns:patch=""  xmlns:role="">
      <fileUploadStorageProvider type="Feature.FormsExtensions.Business.FileUpload.AzureBlobStorageFileUploadStorageProvider, Feature.FormsExtensions">

This provider has 2 parameters: connectionString and blobContainer.

To setup, create a storage account in Microsoft Azure.

Next create a storage container

Choose public access level blob. The name needs to be entered in the blobContainer parameter of the configuration.

The connectionstring can be found on the storage account under Access keys. Copy past the connectionstring under key1 or key2.

That’s it, no further config is required.


Custom Storage Provider

If you require the file to be written elsewhere, you can create your own storage provider.

For this, create a new class and extend from the IFileUploadStorageProvider interface.

    public interface IFileUploadStorageProvider
        IStoredFile StoreFile(HttpPostedFileBase fileBase);

The interface receives a HttpPostedFileBase param containing, the filestream, original filename, content type, etc..

The storefile method should return an implementation of IStoredFile

public interface IStoredFile
        string Url { get; set; }
        string OriginalFileName { get; set; }
        string ContentType { get; set; }
        int ContentLength { get; set; }



The new form upload control also supports 2 new validators: content-type and filesize validator.

Content Type

If you which to restrict the file upload to certain file types. You can enable the ContentType Validator.

When enabled, you need to fill in the Allowed Content Types field and add the content types you which to allow. Add multiple content types on seperate rows.

The validation is done client and server side.

File Size Validator

With the file size validator you can limit the maximum allowed file size of the uploads.

The value is in bytes and is validated client and server side.

Send Email Action

This control is also integrated with the send email to fixed address action of this module. The result will contain the url the $formFields$ and $form_fieldname$ tokens.

Save to database

In the database, a json serialised version of the IStoredFile interface is stored.

This contains the URL, original filename, content type and filesize.

18 thoughts on “File Upload for Sitecore Forms

    1. bart.verdonck says:

      Hi Wilko!
      You can add multiple instances of this component to a single form.
      The component in itself on the other hand is driven by html’s standard and only supports one file.

  1. Hussain says:

    I have installed 1.5.1 package for Upload functionality. But i see that text box fields are disappeared in WEB. I can see those in Experience editor.

    How can i revert back the changes?

  2. Swati says:

    Hello Bart,

    Is it possible to use CDN to send email and upload file in Azure blob, means it will have different URL while I am sending email.

    1. bart.verdonck says:

      Thanks for the suggestion. Currently (1.7), there is no option in the configuration.

      However, you can look at the code of FileSystemFileUploadStorageProvider, copy paste from that one to create your own implementation. And configure the module to use your custom storage provider.

  3. sid says:

    Any way to give CDN url to download the file in email (instead of blob url)?

  4. Luca says:

    is it possible to use the Upload file in order to upload the file into the media library for instance and put this file as an attachment in the email?

    1. bart.verdonck says:

      The problem with this is that you would have to add it to the media library in the master database + publish to web.
      As the CD’s don’t hold a connection to the master database, you would need to intermediately store the file somewhere else anyway and then send a message to the cm to fetch and upload the file in the media library.
      In combination with adding this as an attachment to the mail from the media library, their would be timing conflicts as there are async jobs involved in the process.
      So that’s the reason media lib is currently unsupported. If you really need the files in the media lib as well, I would suggest to create an automation plan to copy the files from the server into media lib.

      Regarding emailing uploads as an email attachment: this is already possible in the module.

  5. Morten says:

    Does it work when ajax is enabled on the form and does it validate client site?

    1. bart.verdonck says:

      Yes, it works with Ajax enabled. On client site, filetype and filesize validation is available.

  6. mun says:

    Hi Bart,

    do you know if there is an issue when this module is used on a sitecore paas( azure app service) ?

    The symptom only happens when the form is ajax-enabled, which is the default.

    the file binary is never attached to the post request form data

    when i set ajax-disabled, the file is a attached properly to the post request.

    1. bart.verdonck says:

      Hi Mun, The module is tested on Sitecore PaaS (and used in production on some of my projects). We are not experiencing issues. Is the module installed on your CD as well as your CM?

  7. Herman says:

    Hi Bart, I’m looking into your Sitecore Forms Extensions to add file-upload fields. Our customer’s visitors upload rather personal information though (CV’s to apply for jobs) so we would wanna implement a Storage Provider where files are not publicly accessible after upload. Even a hard-to-guess GUID in the url is not GDPR-compatible.

    Is there a requirement that the IStoredFile’s Url is accessible? Or could we put a file:///c:\my_secure_folder\cv.doc value in there?

  8. paramjeet says:


    On CD server I get an error : HttpPostedFIleBase is not marked as Serializable. Do you have insight on why we would be getting this ?

  9. Chirayu Brahmbhatt says:

    On client site, filetype and filesize validation is available But is it possible to show error message ?

    I am not able to see at the moment

  10. Jennifer Rose says:

    What steps needs to be taken to ensure that the show / hide; enable/disable conditional behavior is functioning. We have a custom file upload field that works except for in a conditional form. If this field is marked mandatory but is hidden, the mandatory should not prevent a submission, yet it does. Where is this controlled?


Leave a Reply

Your email address will not be published. Required fields are marked *