Using [[!FormItRetriever]] with Input File

Hello everyone!

I’m using a tiny form to upload a file with formIt:



<form action="[[~[[*id]]]]" method="POST" enctype="multipart/form-data">
<input type="hidden" name="nospam" value="" />
<input id="file-upload" type="file" name="fileHere">
<button type="submit" value="Submit" name="sendFileContact">UPLOAD IT</button>

In the page ID 6, once the file is loaded and the user is redirected I got a more complex form with it’s own FormIt call:

    &emailSubject=`Enquiry from [[+full-name]]`


<form..... (more fields)...
<input type="hidden" name="upload-inventory-list" value="[[+fi.fileHere]]" /> 
<button type="submit" value="Submit" name="sendFormContact">SEND</button>

Because the &store = 1 property in the first form and using the [[!FormItRetriever]] in the second form I can see the file with the placeholder: value="[[+fi.fileHere]]"
But I’m not sure how to send the file as an attached file included in this new form.

Any guide please?

Thank you very much!

This might help.

Thanks @bobray but I think I didn’t explain my self.

I’m using a multi page form, in one page I upload the file and what I need is include that file in the second form.
I know there is a security thing that don’t allow adding values to input files, so my question is how can I do that?
Or what is the best way to manipulate that file previously uploaded and attach in the final form.


It doesn’t sound like you really want to send the file as an “attachment” to the email, you want to include the file contents as part of the text, right?

It might work to use a snippet called GetFile at the point where you want the file content inserted with this tag:

[[!GetFile? &filename=`[[+fi.fileHere]]` ]]

The snippet:

$fileName = $modx->getOption('filename', $scriptProperties);
return file_get_contents($fileName);

Well, what I want is to send the file as an attach file!
But no worries I solve it (not as an attached file).

What I did is upload the file into a folder in the server, then using a placeholder I pt the link to the file in an input text.
so the client can click the link and see the file.

Thanks @bobray as always. Have a great day!

IMO, that’s a better solution than making it an attachment. You’ll get better deliverability and it will be more efficient.