HOW TO READ WORD DOCUMENT BEFORE UPLOADING IT BY WEBPAGE

Simons Hood

Total Post:70

Points:494
Posted by  Simons Hood
 865  View(s)
Ratings:
Rate this:

how to read word document before uploading it by webpage

  1. Sumit Kesarwani

    Post:378

    Points:2694
    Re: how to read word document before uploading it by webpage

    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;

    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!