Media library

Since 5.2.0, files sent through a form can also be added to the WordPress media library. Turn it on for each form in the webhook panel, under Advanced settings > Media > Add to Library.

What gets stored

When files are sent as links, each uploaded file is copied to wp-content/uploads/cf7-to-webhook-uploads/<form ID>/<date>_<random>/, with one folder per submission, named with the submission date (UTC) and a random part, such as 20261124_4f1c…. With Add to Library checked, each copy also becomes an attachment that points to that same file, so its URL is the link the webhook gets.

With Send content checked (in the Files section), the webhook gets the file content in base64 and the plugin keeps no copy: Contact Form 7 deletes its own temporary file at the end of the request. Add to Library keeps a copy in that case too, so the file stays in the library.

Who can see the files

The attachments are private. In the media library, only users who can read private posts see them, which by default means administrators and editors.

WordPress does not protect the file itself: anyone with its URL can open it, as with the links sent to the webhook. The URLs are hard to guess because of the random part of the folder name, and the upload folders have an empty index.php, so a server with directory listing on does not list submissions or files.

No resized copies

For images, WordPress usually creates thumbnails, a -scaled version of large images and a -rotated version of photos with an EXIF orientation, and then points the attachment to the new version. The plugin turns this off for its attachments, so each one keeps the original file and URL. WordPress still saves the dimensions, the EXIF data and, for audio and video, the duration.

File types

Every file the form accepts goes to the library. The type comes from the file content: when WordPress does not know the type, or the content does not match the extension, the attachment is saved as application/octet-stream.

Before storing a file, Contact Form 7 renames extensions outside its own safe list: photo.svg becomes photo.svg_.txt, and the same happens to html, js, php, json and others. The server sends these files as plain text, so a script inside them does not run in the browser. A site that changes file names with the wpcf7_upload_file_name filter can undo this rename.

Deleting files

Two options under Advanced settings > Media delete the files of a form, sent as links or not, with their attachments in the media library. Links already sent to webhooks stop working. Only administrators can change them.

Delete after, since 5.3.0, sets a number of days. Once a day, the plugin deletes the files of that form older than that number of days. Days are whole days from midnight UTC, the date in the folder name, so a file stays for at least that many days and at most one more. The default, 0, keeps the files. Folders created before 5.3.0 have no date in the name, so the plugin uses their modification time.

The daily check runs with WP-Cron, which needs a visit to the site to start. On a site with few visits, it may run later than planned.

Delete all files deletes everything uploaded with the form at once: the form folder in cf7-to-webhook-uploads and its attachments. The button also shows how many files the form has and their size.

Deleting a single attachment in the media library deletes its file. The submission folder stays, with its index.php.

For developers

Each attachment has two meta fields:

  • _ctz_contact_form_id: the ID of the form that received the file.
  • _ctz_field: the name of the file field.

The daily check is the WP-Cron event ctz_delete_expired_uploads. With WP-CLI, wp cron event run ctz_delete_expired_uploads runs it now.

To list the attachments of form 123 (see Add custom code for where to put it):

$attachments = get_posts( array(
    'post_type'   => 'attachment',
    'post_status' => 'private',
    'numberposts' => -1,
    'meta_key'    => '_ctz_contact_form_id',
    'meta_value'  => 123,
) );