PHP AutoImport
From OpenKM Documentation
Revision as of 10:22, 8 November 2012 by Jllort (talk | contribs) (Created page with '<source lang="php"> <?php $okmurl="http://localhost:8080/OpenKM/"; $okmid="autoImport"; $okmpw="upload"; $OKMAuth = new SoapClient($okmurl."OKMAuth?wsdl"); $OKMDocume…')
<?php
$okmurl="http://localhost:8080/OpenKM/";
$okmid="autoImport";
$okmpw="upload";
$OKMAuth = new SoapClient($okmurl."OKMAuth?wsdl");
$OKMDocument = new SoapClient($okmurl."OKMDocument?wsdl");
// Login
$token = $OKMAuth->login($okmid, $okmpw);
foreach (glob("/converted/*.pdf") as $filename) {
echo "$filename size " . filesize($filename) . '<br />';
// open file and encode if necessary
$handle = fopen($filename,'rb');
$file_content = fread($handle,filesize($filename));
fclose($handle);
$encoded = base64_encode($file_content);
$filename1 = substr($filename,12);
echo "$filename1" . '<br />';
$OKMDocument->createSimple($token,"/okm:root/imported/".$filename1,$file_content);
//delete the file uoloaded
unlink("c:/converted/".$filename1);
}
// Logout
$OKMAuth->logout($token);
?>