'Is it possible to attach a file created in javascript to a file input field for uploading

I've inherited a rather old application, all forms are done 'old school' without any fancy JavaScript. Multiple forms allow users to upload or replace profile pics of themselves. Now they want to upgrade the site to allow users to use webcams (if available) to take a picture of themselves and upload that instead.

I've got all of the logic in place to take the picture and convert the image to a FileData object.

Question:

Instead of converting all of the forms to send via ajax (which would not be thaaaaat painful I guess...) Is there anyway I can just attach that FormData back into the form so it can be processed 'old school' style again? (Good ole' enctype='multipart/form-data)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source