# Contact Form 7 path for local file

**URL:** https://discourse.roots.io/t/contact-form-7-path-for-local-file/24908
**Category:** bedrock
**Created:** 2023-03-04T01:48:38Z
**Posts:** 3

## Post 1 by @mZoo — 2023-03-04T01:48:38Z

My issue is similar to [this one](https://discourse.roots.io/t/contact-form-7-uploads/23094) 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

wpcf7_uploads/
wpcf7_uploads/.htaccess
# then two lines briefly flash here as the temp file is generated
```

So in debugging I want to try sending a [local file attachment](https://contactform7.com/file-uploading-and-attachment/#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/example.com/current/web/app/uploads/2017/10/image1-150x150.jpeg`
2. `uploads/2017/10/image1-150x150.jpeg`
3. `/srv/www/example.com/releases/20230303203238/web/app/uploads/2017/10/image1-150x150.jpeg`

Running `wp config get WP_CONTENT_DIR` returns:

```
/srv/www/example.com/releases/20230303203238/web/app
```

Any suggestions will be most welcome.

---

## Post 2 by @strarsis — 2023-03-04T16:13:55Z

This should be the path validation function of Contact Form 7 (called from [where the error originates from](https://github.com/takayukister/contact-form-7/blob/6efa44cf62c055bbeb316290b66f405d4bf01946/includes/config-validator.php#L913)):

> <https://github.com/takayukister/contact-form-7/blob/6efa44cf62c055bbeb316290b66f405d4bf01946/includes/validation-functions.php#L225>

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: ).

---

## Post 3 by @mZoo — 2023-03-10T02:50:02Z

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](https://github.com/takayukister/contact-form-7/blob/2ff6732e97ebb28f2d335002a23bca0247f9146e/includes/validation-functions.php#L225)

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

Thanks, as always for the great tools and support.
