I have a JS
code where I can capture, through an input button, the filename
from the file(txt) I selected. How could I possibly send this filename to another view(I know I can't do this directly) and print it there(using puts, for example or any other method).
The JS code:
var fullPath = document.getElementById('file').value;
if (fullPath) {
var startIndex = (fullPath.indexOf('\\') >= 0 ? fullPath.lastIndexOf('\\') : fullPath.lastIndexOf('/'));
var filename = fullPath.substring(startIndex);
if (filename.indexOf('\\') === 0 || filename.indexOf('/') === 0) {
filename = filename.substring(1);
}
}
if(passAll === true){
console.log(filename);
}
}
You can disconsider
the last if and concider
just the console.log