Home > DeveloperSection > Forums > how to read word document before uploading it by webpage
Simons Hood
Simons Hood

Total Post:70

Points:494
Posted on    August-22-2014 1:44 AM

 ASP.Net ASP.Net 
Ratings:


 1 Reply(s)
 616  View(s)
Rate this:

how to read word document before uploading it by webpage



Sumit Kesarwani

Total Post:378

Points:2694
Posted on    August-22-2014 2:09 AM

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;

}


Don't want to miss updates? Please click the below button!

Follow MindStick