given a path of a file like:
C:\file.jpg
how can i get the size of the file in javascript?
views:
73answers:
5You can't get the file size of local files with javascript in a standard way using a web browser.
But if the file is accessible from a remote path, you might be able to send a HEAD request using Javascript, and read the Content-length header, depending on the webserver
If it's not a local application powered by JavaScript, you can't. Web pages running javascript do not have access to the local filesystem for security reasons.
You can use a graceful degrading file uploader like SWFUpload if you want to show a progress bar.
You cannot.
JavaScript cannot access files on the local computer for security reasons, even to check their size.
The only thing you can do is use JavaScript to submit the form with the file field to a server-side script, which can then measure its size and return it.
If you could access the file system of a user with javascript, image the bad that could happen.
However, you can use File System Object but this will work only in IE:
http://bytes.com/topic/javascript/answers/460516-check-file-size-javascript