Hi! đź‘‹
I’m having trouble updating a record when a form includes a file upload field.
-
What works:
-
Updating common fields (text, textarea, number, calendar) works with no issues.
-
File upload itself works: the file is moved into the correct folder.
-
Insert into my custom table works fine when the user uploads their first file.
-
-
The problem:
-
When the user tries to upload a second file (different column in the same row), the file uploads to the folder but the database column does not update.
-
If the user tries to replace an existing file in the same column, the new file uploads, but the table column still keeps the old filename (no update happens).
-
-
My setup:
-
WordPress + ChronoForms v8.
-
Custom table with ~10 file columns.
-
Each user has exactly one row in this table.
-
First file insert works fine, but subsequent updates don’t work for file fields.
-
Has anyone else run into this behavior with file upload fields in CFv8? Is there a recommended way to make file upload fields update existing rows (similar to how text fields update correctly)?
Thanks in advance for any guidance! 🙏
Hi xoles
Enable the form debug and check the part of saving to database, does it show the new data being saved or old data ? you may also post the debug here after you remove any private info
Many thanks, Max!
Here is the debug result after trying to update an existing record with a new filename.
-
The original data remains in all arrays (Data, Vars, Info).
-
The
file
array does not show the new filename of the attempted update. -
So the upload itself works, but the Save Data action keeps the old value and does not update the column.
I’ve been tweaking all possible configuration combinations:
-
Tried with one Save Data action (with primary key, and external DB where
user_id IN {user:id}
and switching values/fields). -
Also tried with two Save Data actions: one for update (with where + run condition) and another for insert (no where, only run condition).
In both cases the behavior is the same: filename field do not update.
I’ve attached screenshots of my configuration and the debug output (some info removed).
Debug
Data
Array
(
[step] => 2
[chronoform] => file01
[id_files] => 1123
[user_id] => 1
[created] => 2025-09-23 23:35:55
[modified] => 2025-09-23 23:35:48
[file01] => unnamed_20250923_233555.png
[file02] => NULL
)
Files
Array
(
)
Vars
Array
(
[app_active_page] => 3
[read_data11] => Array
(
[id_files] => 1123
[user_id] => 1
[created] => 2025-09-23 23:35:55
[modified] => 2025-09-23 23:35:48
[file01] => unnamed_20250923_233555.png
[file02] => NULL
)
[php21] => NULL
)
Info
Array
(
[read_data11] => Array
(
[sql] => SELECT * FROM `files` WHERE user_id = 1 LIMIT 1 OFFSET 0
[returned] => Array
(
[id_files] => 1123
[user_id] => 1
[created] => 2025-09-23 23:35:55
[modified] => 2025-09-23 23:35:48
[file01] => unnamed_20250923_233555.png
[file02] => NULL
)
)
[php21] => Array
(
[returned] => NULL
)
)
Hi Max, I figured it out. I always felt it was a simple fix, that I was missing or overlooking (tired of tweaking), and that it was not a bug.
Solution: two Save Data actions.
Insert Save Data action with no where condition/statement and run condition for primary key is empty.
Update Save Data action with where statement for primary id and run condition for primary key is not empty.
Both include user_id in table fields and obviously catching primary key from read data action.
If I find something else to complement this post, I will gladly post it for the community.
Thanks for your support!