var fileInput = $('#files');
var uploadButton = $('#upload');
uploadButton.on('click', function () {
if (!window.FileReader) {
alert('Your browser is not supported')
}
var input = fileInput.get(0);
// Create a reader object
var reader = new FileReader();
if (input.files.length) {
var textFile = input.files[0];
reader.readAsText(textFile);
$(reader).on('load', processFile);
} else {
alert('Please upload a file before continuing')
}
});
function processFile(e) {
var file = e.target.result,
results;
if (file && file.length) {
results = file.split("\n");
console.log(results)
$('#name').val(results[0]);
$('#age').val(results[1]);
}
}
<input type=file id=files />
<button id=upload>Upload</button>
<br/><br/>
<input type=text id=name /><br/>
<input type=text id=age />
上面的代码用于上传文件并在文本框中打印文件的内容。上面的代码没有错误,但devextreme移动上传按钮不起作用。为什么会这样?
我很抱歉我的英语不好