Add File Types to File Upload Fields in WordPressPRO

By default, WordPress restricts which file types can be uploaded for security reasons. If you’re using a File Upload field in WS Form and want to allow additional file types (such as .svg, .zip, or other custom formats), you can enable them by adding a simple code snippet to your website.

Step 1: Allow Additional File Types in WordPress

To enable additional file types, use the upload_mimes filter in WordPress. Add the following code to your theme’s functions.php file or use a plugin like Code Snippets to add it safely:

add_filter( 'upload_mimes', 'wsf_allow_additional_mime_types' );

function wsf_allow_additional_mime_types( $mimes ) {

    // Example: Allow SVG and ZIP files
    $mimes['svg'] = 'image/svg+xml';
    $mimes['zip'] = 'application/zip';
    
    // Add more file types as needed:
    // $mimes['ext'] = 'mime/type';

    return $mimes;
}
Only allow file types you trust. Enabling certain formats (e.g., SVG) may require extra sanitization for safe use.

Step 2 (Optional): Restrict File Types in WS Form

Once WordPress allows additional file types, you can optionally restrict which types are permitted for a specific File Upload field in WS Form.

  • Edit your form in WS Form.
  • Click the File Upload field to open its settings.
  • In the Allowed File Types setting, enter the file extensions you want to accept (e.g., svg, zip).
  • Save your form.

This step is not required, but it allows you to limit uploads to specific file types at the form level.

Learn more: File Upload Accept Parameters

Step 3: Test Your Form

Preview or publish your form and try uploading a file using the new extension. If configured correctly, the file should upload successfully without errors.

Additional Notes

  • Some file types (e.g., .svg) may not preview properly in the WordPress media library unless additional plugins or sanitizers are used.
  • If uploads still fail, check server-level restrictions (e.g., MIME type filtering in PHP or NGINX/Apache).
  • Use a trusted MIME type reference: Common MIME Types (MDN)