Asked by Wilson Edwards
at 2024-08-27 19:05:39
Point:500 Replies:2 POST_ID:829243USER_ID:12108
Topic:
javascript;file object;html
I would like my editor has function in which user can upload their files on widow 11 converted to be href DataUrl link .
I try this not work:
- if (file.type.indexOf("text") == 0) {
- var reader = new FileReader();
- var charset='charset=utf-8;base64,';
- reader.onload = function(e) {
- var href=''data:"+charset+btoa(e.target.result);
- var html_str=""+file.name+"";
- }
- reader.readAsText(file);
- }
when I click the a href link, on window, it won't download the file, only text file can work
how about make excel, xls format file, work also ?
Any easy suggestion ?
Please advise
Regards