Contact Form 7 path for local file

My issue is similar to this one where dev needed to configure WPCF7_UPLOADS_TMP_DIR.

However, I can see that CF7 is creating the attachments for the form’s file element using this handy tool:

current/web/app/uploads$ watch -d find wpcf7_uploads/

Which gives something like this:

Every 2.0s: find wpcf7_uploads/                    project-ubuntu-s-1cpu-1gb-nyc3: Sat Mar  4 01:35:49 2023

# then two lines briefly flash here as the temp file is generated

So in debugging I want to try sending a local file attachment, but can’t seem to find a local path that will satisfy CF7.

It reports:

It is not allowed to use files outside the wp-content directory.

for paths:

  1. /srv/www/
  2. uploads/2017/10/image1-150x150.jpeg
  3. /srv/www/

Running wp config get WP_CONTENT_DIR returns:


Any suggestions will be most welcome.

This should be the path validation function of Contact Form 7 (called from where the error originates from):

You can hold the debugger here and check why the path fails the check (or just pepper in some var_dump/exit stuff (on development of course) :wink: ).


With plenty of help from xdebug (and having benefited greatly from the Roots/Trellis xdebug video,

Our approach was, to get past validation for our Roots/Bedrock instance, contact-form-7/validation-functions.php at 2ff6732e97ebb28f2d335002a23bca0247f9146e · takayukister/contact-form-7 · GitHub

Then added a new php global define('UPLOADS', '../app/uploads'); in site/config/application.php.

Thanks, as always for the great tools and support.

1 Like