PHP AutoImport
From OpenKM Documentation
(Redirected from AutoImport)
Import pdf files from some local /converted/*.pdf path to specific OpenKM server path
<?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);
?>