Advertise with us

how to read word document before uploading it by webpage

how to read word document before uploading it by webpage

Last updated:8/22/2014 2:09:25 AM

1 Answers

Sumit Kesarwani
Sumit Kesarwani

Hi Samuel ,


You probably need an ActiveX Object to access the file content on the client system before uploading.

function CheckWordDoc(filepath){
    var fso, f, ts, s;
    var ForReading = 1, ForWriting = 2, ForAppending = 8;
    var TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0;
    fso = new ActiveXObject("Scripting.FileSystemObject");
    f = fso.getFile(filepath);
    ts = f.OpenAsTextStream(ForReading, TristateUseDefault);
    while (!ts.AtEndOfStream) {
        s = ts.ReadLine();
        if (s.indexOf("Word.Document.8") != -1) {
            ts.Close( );
            return true;
        }
    }         
    ts.Close( );
    return false;
}

Last updated:8/22/2014 2:09:25 AM

Answer