How exactly does Formit process Attachments?

Hey guys - how does Formit handle input fields like this?
<input type="file" name="test" id="test">

What exactly happens after submitting my form using the basic email hook?

The file gets attached to the email and is sent successfully - but is this true at all? Does it get attached? To me it seems as if the files get somehow embedded.

So: What exactly happens technically? I would like to get a better understanding of what actually happens there. The attachment is stored temporarily on the server? Where? For how long?

Are those system settings relevant?


PS: My form works just fine, I don’t need help setting this up. I need help in understanding how it works.

So how exactly does your FormIt snippet call look like? Like this?


This looks like the file gets attached normally.

Yes. In assets/components/formit/tmp. Probably forever.

If think they are only used in the FormItSaveForm hook.

1 Like

This is only true if the property &saveTmpFiles is set to 1.

Otherwise the file is attached to the mail directly from the temporary directory and should get deleted at the end of the request. See the documentation about $_FILES:

The file will be deleted from the temporary directory at the end of the request if it has not been moved away or renamed.

1 Like

Thanks for your input, @halftrainedharry !

My Formit snippet call does not include any of these properties:

saveTmpFiles → because I don’t want the files to be stored on the server
allowFiles → not set because true is default
attachFilesToEmail → not set because true is default

So my Formit snippet call really has nothing special going on.

For my understanding the processing is like this:

1) file gets chosen via input
2) on submit the file is uploaded into a tmp directory as written in the documentation:

Files will, by default be stored in the server’s default temporary directory, unless another location has been given […]

3) mail is being sent
4) file gets deleted from tmp directory

Just to correct myself a second time. Even files stored with &saveTmpFiles=`1` get removed after 1 day.


Thank you very much for helping me understand the details, @halftrainedharry

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.