I am looking for a solution in PHP to identify the document (doc,docx,xls,xlsx) is password protected or not?
Got a solution
$word=new COM("word.application") or die("Cannot create Word object");
$word->Visible=false;
$word->WindowState=2;
$word->DisplayAlerts=false;
// $doc = $word->Document->Open(realpath("C:\wamp\www\test\pro_1.docx"));
$doc = $word->Documents->Open(realpath("pro_1.docx"));
var_dump($doc);
exit();
$passwordProtect = $doc->Document->HasPassword;//true or false
var_dump($passwordProtect);
$word->ActiveDocument->Close(false);
$word->Quit();
$word->Release();
$word=null;
In this, the Documents->Open is through me an error... any other better solution or can somebody tell me how this code will work?