Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to read file uploaded in Drag & Drop #102

Open
leorcdias opened this issue Sep 20, 2019 · 0 comments
Open

How to read file uploaded in Drag & Drop #102

leorcdias opened this issue Sep 20, 2019 · 0 comments

Comments

@leorcdias
Copy link

I am trying to read an XLSX file when uploading in the "Drag & Drop" field. How can I do this without using jQuery's change function?

My project is part of a college assignment, which I am due to deliver this Saturday, and I have problems with that part :(

Library used to read XLSX: SheetJS

My JS Code:

function uploadedXLSX(e) {
let reader = new FileReader();
reader.readAsBinaryString(e.target.files[0])
reader.onload = (e) => {
let data = e.target.result;
let workbook = XLSX.read(data,{type: 'binary'});
let first_sheet_name = workbook.SheetNames[0];
let worksheet = workbook.Sheets[first_sheet_name];
let jsonObj = XLSX.utils.sheet_to_json(worksheet,{raw: false});
return orderData(jsonObj)
}
}

$(document).ready(function () {
$('#fileUploader').change(function (e) {
uploadedXLSX(e);
});
});

dmUploader Config:

url: 'backend/upload.php',
maxFileSize: 5000000, // 5 Megs,
extFilter: ["xls", "xlsx"],
multiple: false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant