Hi everyone,
I am still fairly new to coding but I am finding my way around it and really enjoying the learning process so far! I have quite a tricky problem that I am trying to overcome, but I am battling to research this idea as I don’t even know what to search for.
Some quick background info: I have created a Leaflet.Draw map that allows the user to download a drawn feature as a .kml file. When the submit button is clicked, the feature is exported and a contact form (as a modal) pops up which allows the user to provide some info and attach their exported feature (take a look at the screenshot).
I thought it would be really cool if the exported feature was automatically uploaded to the form’s attachment input. Is something like this possible?
Here is the export script:
document.getElementById('export').onclick = function(e) {
// Extract GeoJson from featureGroup
var data = featureGroup.toGeoJSON();
var kml = tokml(data);
// Convert to dataURL format
var convertedData = 'application/vnd.google-earth.kml+xml;charset=utf-8,' + encodeURIComponent(kml);
// Create export
document.getElementById('export').setAttribute('href', 'data:' + convertedData);
document.getElementById('export').setAttribute('download','data.kml');
}
And the attachment part of the form
<input type="file" name="file_attach[]" multiple data-required="true"/>
Does anyone possibly have some advice, or know where I could find some more information regarding this idea? Thanks 
