You are viewing limited content. For full access, please sign in.

Question

Question

Forms - uploading a file to an official file upload field with Script

asked on November 7, 2023

I have started working with some custom file upload fields for different purposes like parsing a CSV or converting the file type that was uploaded.

I have a case where we want to convert an uploaded file from an Apple format to a Microsoft format but then upload the Microsoft format to the repository. So that Apple users can use the same form as Windows users are using without issue.

The problem with custom upload fields is there is no variable to access in the process diagram's Save to Repository task.

So I tried the following solution and I get no errors, but I do not see the file in the resulting output field

let fileInputElement = document.getElementById('Field2');
    fileInputElement.files = document.getElementById('content-target'),input.files[0];

 

0 0

Answer

SELECTED ANSWER
replied on November 7, 2023 Show version history

Forms file uploads are more complicated; the field sends the file to the server immediately and the form picks up that temp file on submission, probably to control the size of the POST.

Basically, the input on the form is just a middleman, so you can set the value, but that doesn't trigger all the other functions that run to store it properly.

For example, running the following will always return 0 files even if you uploaded them directly to the out-of-the-box input field.

 document.getElementById('Field2').files

To do what you're trying to do, you'd need a way to trigger the functions that run on the out-of-box input because setting the value doesn't seem to be enough even if you trigger a change event.

1 0
replied on November 8, 2023

Ok, thanks for the explanation. We may have to convert and download, then ask them to upload the converted file.

0 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.