Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
95
rated 0 times [  100] [ 5]  / answers: 1 / hits: 149964  / 14 Years ago, thu, june 3, 2010, 12:00:00

given a path of a file like:

C:file.jpg

how can i get the size of the file in javascript?


More From » javascript

 Answers
9

If it's not a local application powered by JavaScript with full access permissions, you can't get the size of any file just from the path name. Web pages running javascript do not have access to the local filesystem for security reasons.


HTML5 has the File API. If a user selects the file for an input[type=file] element, you can get details about the file from the files collection:


<input type=file id=fileSelector>

fileSelector.onchange = () => {
alert(fileSelector.files[0].size);
}

[#96593] Tuesday, June 1, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dannyc

Total Points: 517
Total Questions: 106
Total Answers: 116

Location: Netherlands
Member since Mon, Jun 7, 2021
3 Years ago
;