Access file properties through PHP
In windows explorer their is a summary tab that contains, title, subject, author, category, keywords, and comments for every file. Is it possible to read and edit this data usin开发者_高级运维g php?
You can't get meaningful metadata with PHP in windows for many applications. The only real exception for this would be using PHP's Component Object Model.
Reference
http://www.php.net/manual/en/intro.com.php
Here is an example for word / excel:
// for MSExcel use:
$objOfficeApp = new COM("excel.application") or die("unable to instantiate MSExcel");
// for MSWord use:
//$objOfficeApp = new COM("word.application") or die("unable to instantiate MSWord");
$objOfficeApp->Workbooks->Open( "c:\\temp\\test.xls" );
//$objOfficeApp->Documents->Open( "c:\\temp\\test.doc" );
$objDocProps = $objOfficeApp->ActiveWorkBook->BuiltInDocumentProperties();
//$objDocProps = $objOfficeApp->ActiveDocument->BuiltInDocumentProperties();
$count = $objDocProps->count();
while( $objDocProp = $objDocProps->Next() ) {
print $objDocProp->Name() . ': ' . $objDocProp->Value() . "\n";
}
unset($objDocProp);
unset($objDocProps);
$objOfficeApp->ActiveWorkBook->Close();
//$objOfficeApp->ActiveDocument->Close();
$objOfficeApp->Quit();
unset($objOfficeApp);
精彩评论