I am currently developing an application that allows users to upload files. Before uploading the file, I need to configure the file storage settings. The first step is to read the first ten rows of the file and display them to the user. The user can then provide the necessary configuration, and I will proceed with uploading the file.
I have attempted the following approach:
<script>
document.getElementById('file').addEventListener('change', readSingleFile, false);
function readSingleFile(evt) {
var FileBlock = "";
var contents="";
var f = evt.target.files[0];
if (f) {
var r = new FileReader();
r.onload = function (e) {
contents = e.target.result;
var Rows = contents.toString().split("\n", 10);
FileBlock = Rows[0];
for (var i = 1 ; i < Rows.length; i++) {
FileBlock += "|" + Rows[i];
}
alert(contents);
@{
Session["Test"] = @:contents+"";
}
OpenDockPanelBySumbitForm("ImporterPanel", "form",FileBlock);
Hide_ContentZone_Panel();
}
r.readAsText(f);
} else {
alert("Failed to load file");
}
}
I have encountered an issue with this piece of code.
@{
Session["Test"] = @:contents+"";
}
If anyone has suggestions or can provide assistance, I would greatly appreciate it. Thank you for your participation.