EE 5.2.2
I'm using the {exp:channel:form}
tag to create an order reporting feature that will save a generated report as an EE channel entry.
The feature currently has a form that accepts parameters, submits those to an Amazon API, and returns the result (XML report for orders) as a JSON object. If the object is received successfully then the old form is hidden and a new form is shown. This form is a {exp:channel:form}
tag.
I've been able to get this tag to submit an entry to the channel with a title that is generated based on the previously submitted parameters, and that works fine. I also have two links that show along with the new form as a part of the result of this query: a link to view the new file and a link to download it (these are both done using the JavaScript Blob object, and both of them are working:
var file = new Blob([text], {type: type});
a.attr('href', URL.createObjectURL(file));
a.attr('download', name + '.txt');
v.attr('href', URL.createObjectURL(file));
t.attr('value', name);
The problem I'm having now is this: how to save this new file in a input (preferably hidden) that can be submitted to the channel along with the title?
I have these two docs open: this one and this one. I'm not quite sure how to interpret this, though. They both have this as an example:
<input type="file" name="my_field_name" />
<input type="hidden" name="my_field_name_directory" value="1" />
<input type="hidden" name="my_field_name_hidden_file" value="{my_field_name}{file_name}{/my_field_name}" />
What I have in my form is this:
{exp:channel:form channel="order_reports" return="/{my_index}"}
<a href="" id="download_link">Download File</a>
<a href="" id="view_link" target="_blank">View File</a>
<input type="hidden" name="title">
<input type="file" name="my_field_name" />
<input type="hidden" name="my_field_name_directory" value="1" />
<input type="hidden" name="my_field_name_hidden_file" value="{file}{title}{/file}" />
<input type="submit" value="Save">
{/exp:channel:form}
Now, I'm obviously not doing this right, but I'm not entirely sure how to interpret the documentation. And I'd ideally like to put this new file into a hidden input so the user doesn't have to go through another step to save the file to the channel, so if there's some way that I could put my Blob object into an input as a .txt file, the same way I'm doing it with my two links, that would be perfect.
Thanks for any help and/or clarification.