惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The Cloudflare Blog
U
Unit 42
F
Fortinet All Blogs
雷峰网
雷峰网
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
月光博客
月光博客
Y
Y Combinator Blog
罗磊的独立博客
V
Visual Studio Blog
大猫的无限游戏
大猫的无限游戏
J
Java Code Geeks
量子位
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
爱范儿
爱范儿
B
Blog RSS Feed
aimingoo的专栏
aimingoo的专栏
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
Microsoft Security Blog
Microsoft Security Blog
L
LangChain Blog
I
InfoQ
博客园 - 叶小钗
博客园 - 聂微东
Last Week in AI
Last Week in AI

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
CF7 File Uploads: Why the Attachment Never Arrives in You...
Rahul Sharma · 2026-06-15 · via DEV Community

Two developers posted the same problem on the WordPress forums. Both had the CF7 file field set up correctly in the form. Both had [your-file] in the Mail tab. Neither received the file as an attachment in their email.

One developer found the fix in a video. Here is what the video showed that the CF7 documentation does not mention anywhere:

There is a third place you need to add the file tag — the File Attachments field at the bottom of the Mail tab. Most people never scroll down far enough to see it.

That is the entire fix. But understanding why CF7 works this way, what each of the three placements actually does, and how to handle file uploads that need to go somewhere beyond email is worth covering properly.

The Three Places the File Tag Goes (And What Each One Does)

CF7's file upload has three completely separate functions that require separate tag placements:

Placement 1: The Form Tab

[file your-file filetypes:pdf|doc|docx limit:2mb]

This renders the file input element in the HTML form. Without this, users have no way to select a file. This is the only placement that most tutorials cover.

Placement 2: The Mail Tab Body

School/Organization Logo: [your-file]

This inserts the filename (not the file itself) into the email body as text. It tells you what file was uploaded but does not attach it. This is where the confusion starts. Both developers in the thread had this placement and assumed it would attach the file. It does not. It just prints the filename as a string.

Placement 3: The Mail Tab File Attachments Field

[your-file]

This is the field that actually attaches the file to the outgoing email. It is at the bottom of the Mail tab, below the Message Body field. It is easy to miss because it is small, unlabelled in some CF7 versions, and completely absent from the official documentation.

Without this third placement, the file is uploaded to your server (wp-content/uploads/wpcf7_uploads/) but never attached to the email. The email arrives with the filename mentioned in the body but no attachment.

Step by Step: Correct CF7 File Upload Configuration

Step 1: Form Tab

Use the File button in the CF7 form editor toolbar to insert the tag (do not type it manually — the UI generates a clean tag with the correct format):

[file file-upload filetypes:pdf|doc|docx|jpg|png limit:5mb]

Common mistakes in the form tag:

  • filetypes:image/* with the wildcard — some servers reject this. Use explicit types: image/jpeg|image/png|image/gif
  • Setting limit too high — hosting providers often have a lower upload_max_filesize in php.ini than what you set in CF7. CF7's limit cannot exceed the server's PHP limit

Step 2: Mail Tab Body (Optional)

Add this where you want the filename to appear in the email body:

Uploaded file: [file-upload]

This is optional. If you only want the attachment without mentioning it in the body, skip this placement.

Step 3: Mail Tab File Attachments Field (Required for Attachment)

Scroll to the bottom of the Mail tab. Find the field labelled File Attachments (it may be collapsed or hidden below the message body area). Add:

[file-upload]

This is the step that actually causes the file to be sent as an email attachment. Without it, the file exists on your server but never reaches the recipient's inbox.

The Filetypes Wildcard Problem

The original poster used filetypes:audio/*|video/*|image/* with wildcards. This is a CF7-supported syntax but can cause issues on some server configurations where the MIME type detection does not resolve wildcards correctly.

The safer approach is explicit MIME types:

[file your-file filetypes:image/jpeg|image/png|image/gif|image/webp|audio/mpeg|video/mp4 limit:1mb]

Or for common document uploads:

[file your-file filetypes:pdf|doc|docx|xls|xlsx|txt limit:5mb]

CF7 accepts both MIME type strings and file extensions. File extensions are simpler to read and work reliably across server configurations.

Where Uploaded Files Actually Go

Files uploaded through CF7 go to wp-content/uploads/wpcf7_uploads/ temporarily. CF7 deletes them after the email is sent. They are not permanently stored on your server.

This is what the original poster saw in Flamingo: a number (the temporary file ID) rather than a clickable link. Flamingo records that a file was submitted but does not store the file itself. Once CF7 processes the form and sends the email, the file is gone from the server.

If you need permanent file storage (files accessible after the email is sent), you have two options:

Option 1: Use a plugin like "CF7 to Post" or "CF7 Storage" to save uploads permanently alongside the form submission record.

Option 2: Forward the file to external storage via API. Contact Form to API can send form submission data including file references to an external endpoint where the file can be stored in cloud storage (S3, Google Drive, Dropbox, etc.) as part of a webhook workflow.

Making Fields Optional

The second question in the thread: how to make certain fields optional.

In CF7, field tags with an asterisk are required:

[text* your-name]    <- required
[text your-company]  <- optional

Remove the asterisk to make a field optional. For file uploads:

[file your-file filetypes:pdf limit:5mb]         <- optional upload
[file* your-file-required filetypes:pdf limit:5mb] <- required upload

Optional file fields do not block form submission if left empty. Required fields with * trigger CF7's validation and prevent submission if no file is selected.

Quick Reference

Placement Location What it does
[file your-file ...] Form tab Renders the file input in the HTML form
[your-file] in body Mail tab body Inserts the filename as text in the email body
[your-file] in File Attachments Mail tab bottom Actually attaches the file to the outgoing email

All three are needed if you want the file to appear as an email attachment. The third one is the one nobody mentions and the one that solves the problem.