Difference between revisions of "PHP AutoImport"
From OpenKM Documentation
(Created page with '<source lang="php"> <?php $okmurl="http://localhost:8080/OpenKM/"; $okmid="autoImport"; $okmpw="upload"; $OKMAuth = new SoapClient($okmurl."OKMAuth?wsdl"); $OKMDocume…') |
|||
Line 31: | Line 31: | ||
?> | ?> | ||
</source> | </source> | ||
+ | |||
+ | [[Category: Utilities]] |
Revision as of 10:23, 8 November 2012
<?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);
?>