Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,885 questions

51,811 answers

573 users

How to get the name, size and type of the selected file from disk in JavaScript

1 Answer

0 votes
function get_file_info() {
    var file_name = document.getElementById('file').files[0].name;
    var file_size = document.getElementById('file').files[0].size;
    var file_type = document.getElementById('file').files[0].type;
    
    document.write(file_name + "<br />");
    document.write(file_size + " bytes" + "<br />");
    document.write(file_type + "<br />");
}
 
 
/*
run:
 
abc.zip
6473536 bytes
application/x-zip-compressed
    
*/
<input type="file" id="file" onchange="get_file_info()"/>

 



answered Sep 16, 2019 by avibootz
...