HTML5 path and file path

I am wondering where the file path is stored in a File object in HTML javascript.

I used Webkit DevTools and got the following:

FileList 0: File fileName: "script.js" fileSize: 71268 name: "script.js" size: 71268 type: "application/x-javascript" __proto__: File length: 1 __proto__: FileList 

The name of the file, its size and types (who knows why the name and size have 2 variables), but the path is not specified.

Is there a way to find the path to the file, and if not, how does the browser and javascript read the file (for example, POST methods and determine the type and size)?

+7
javascript html file html5
source share
1 answer

As you can read in the WHATWG HTML spec ,

[f] or historical reasons, value The IDL attribute is the prefix of the file name with the string "C: \ fakepath". Some legacy user agents actually included the full path (which was a secure vulnerability).

Reading on MDC , we see that the Mozilla implementation of the File object has a (non-standard) property called mozFullPath containing

[t] full path of the file link; available only for code UniversalFileRead rights in chrome.

This page also answers your question about redundant data in the File object: the fileName and fileSize are deprecated. Also look at the W3C Work Project API File where they are not mentioned.

To answer the second part of your question:

If not, how does the browser and JavaScript read the file (for example, POST methods and determine the type and size)?

Of course, the internal file path may be accessible (and located in several browsers shown to the user), but it is not available for JavaScript scripts running on a web page.

By the way, a few years ago there was a discussion about this on the WHATWG mailing list .
+8
source share

All Articles