-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsfmc_cloudpages_de_creator
40 lines (39 loc) · 1.27 KB
/
sfmc_cloudpages_de_creator
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
*/Created by Jason Hanshaw/*
For reference: https://salesforce.stackexchange.com/questions/283339/how-to-insert-csv-file-record-inside-data-extension-from-cloud-page
<form method="post" action="YOUR PROCESSING PAGE" id="csv_upload">
<p>
Upload File:
</p>
<input id="csvUpload" type="file" name="file"/>
<input type="hidden" maxlength="" name="csv" id="csv" value="" />
<br/>
<br/>
<button id="button" type="submit">Submit</button>
</form>
<script >
function uploadDealcsv() {};
uploadDealcsv.prototype.getCsv = function(e) {
let input = document.getElementById('csvUpload');
input.addEventListener('change', function() {
if (this.files && this.files[0]) {
var myFile = this.files[0];
var reader = new FileReader();
reader.addEventListener('load', function(e) {
let csvdata = e.target.result;
parseCsv.getParsecsvdata(csvdata);
});
reader.readAsBinaryString(myFile);
}
});
}
uploadDealcsv.prototype.getParsecsvdata = function(data) {
let parsedata = [];
let newLinebrk = data.split("\n");
for (let i = 0; i < newLinebrk.length; i++) {
parsedata.push(newLinebrk[i].split(","))
}
document.getElementById("csv").value = parsedata;
}
var parseCsv = new uploadDealcsv();
parseCsv.getCsv();
</script>