1

I am using below code to select a directory and read each file from that directory

<input type="file"onchange="checkFiles(this.files)" webkitdirectory directory multiple>

In below code I am able to read each files in directory and it properties like name, size and type. But did not found any way to check if files are readable, writable or executable.

function checkFiles(files) {
    for (var i = 0; i < files.length; i++) {
        //check for readable writable or executable files
    }
}
raoul.nair
  • 389
  • 1
  • 8
  • 21

1 Answers1

0

If writeable = not read-only then maybe you can try to use this example. As Dan-o mentioned, this will only work for internet explorer.

For other browsers compatibility, try to dig in into activex object in firefox or chrome not ie.

function get() {
    var myObject, f;
    myObject = new ActiveXObject("Scripting.FileSystemObject");
    f = myObject.GetFile("c:\\test.txt");

    if(!f.attributes) {
        //No attributes set
    }
    else {

        if (f.attributes & 1) {
            //Read only
        }

        else if (f.attributes & 2) {
            //Hidden
        }

        else if (f.attributes & 4) 
            //System
        }

        else if (f.attributes & 8) { 
            //Volume label
        }

        else if (f.attributes & 16) {
            //Folder
        }

        else if (f.attributes & 32) {
            //Archive bit set
        }

        if (f.attributes & 64) {
            //Shortcut or link
        }

        if (f.attributes & 128) {
            //File is compressed
        }
    }

You can combine this with gettnig the MIME type of a file.

Community
  • 1
  • 1
Marek
  • 3,935
  • 10
  • 46
  • 70