07967 325669 info@mootpoint.org

Gravity Forms allows file uploads as part of a form submission. Lucas Stark’s WooCommerce Gravity Forms add-on allows file uploads to be attached to products in WooCommerce. These files are stored in the uploads folder, in subfolders containing long alphanumeric strings to prevent unauthorised access. For example:

/public_html/wp-content/uploads/gravity_forms/16-f57410eca19713ef56bc4faab7a7c1e6d/2014/11

If you are getting a lot of uploads, the server space used by the files can quickly mount up, requiring some regular housekeeping to free up space.

Manually removing expired form entries

Once you have finished with the submitted forms you can remove them from the admin interface.

  1. Go to Forms in admin.
  2. Click on the number of entries in the Entries column for the form you are working with.
  3. In the search filter, select Entry Date + less than and enter a cutoff date in the format YYYY/MM/DD. e.g to delete entries older than 01/04/2014 enter 2014/04/01.
  4. Click Search.
  5. Select the checkbox under the Bulk action drop down to select all the entries. Click the Select all XXX entries link that appears.
  6. In the Bulk action drop down, select Trash and click Apply.
  7. Click the Trash link at the top of the list.
  8. Select the checkbox under the Bulk action drop down. Select the Delete Permanently bulk action and click Apply to delete the entries permanently from the Trash.

Notes:

  • Use the Switch Form drop down to select the correct form.
  • Removing entries in this way also deletes the files uploaded with each entry.

Beware: Once the entries have been permanently deleted from the trash, they cannot be recovered.

Automatically removing expired Gravity Forms entries

Travis Lopes’ Entry Expiration For Gravity Forms does a nice job of clearing out entries after a set period. Uploaded files are deleted when the form entry is deleted.

As the clear out process is triggered by wp_cron, you may want to set up a proper cron job to trigger wp_cron if you don’t get much traffic to your site.

Removing temporary files

Gravity Forms stores uploaded files in a temporary folder while they are uploading, before transferring them to their final location. If the upload process doesn’t complete for some reason, you can end up with a bunch of files in the tmp folder. For example:

/public_html/wp-content/uploads/gravity_forms/16-f57410eca19713ef56bc4faab7a7c1e6d/tmp

It is probably safe to remove files in the tmp folder that are more than say 3 days old. To do this, SSH into your server space and run the following command:

find public_html/wp-content/uploads/gravity_forms/*/tmp* -mtime +3 -exec rm -f {} \;

Notes:

  • The path contains wildcards to match the Gravity Forms folder pattern.
  • -mtime +3 means find files with date modified greater than 3 days ago.
  • -exec rm -f {} executes a delete on matched files only.

Update 26/09/2016: It might be best to leave these in place. GF uses the tmp folder to store entries which have been saved for later completion. Thanks for the tip Shaun!