Forums

possible to change value before it goes into database

SAGO 29 Mar, 2012
Hi,

using CFv3.2

I have a form with several fields which get stored into a table in a DB after submitting.
One of the fields is a upload file field called upload_file.
1) Would it be possible to change the value before it gets stored.
By the way: I've set "Before E-mail" for "Saving Data/Emails order:" under DB connections just so you know.

Example, you upload: sample.mpeg and click on submit.
With some php code I'm going to try to convert it to for example a mp4.
Now I want to store the new name for example sample_converted.mp4 into that field (or in a hidden field now that I think of it, as long as it gets stored in the database)

You can assume that I will have the new name in a string $newName.
2) Where do I need to put the code to manipulate the current value of a field? Is it in the "On Submit code - before sending email" or "On Submit code - after sending email:" or somewhere else?
3) How do I change the value. What code do I need to use?

Thanks in advance. I would really appreciate some help.

Sago
GreyHead 07 Apr, 2012
Hi SAGO,

You can add PHP in the Upload Files | File Name box so, yes it is possible to change the name. And I think that the Upload files code is executed very early on so the revised name should be available for the Email.

Bob
This topic is locked and no more replies can be posted.