add.php
1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
require_once("../../config/dmsDefaults.php");
require_once(KT_LIB_DIR . '/documentmanagement/documentutil.inc.php');
require_once(KT_LIB_DIR . '/filelike/fsfilelike.inc.php');
error_reporting(E_ALL);
$oFolder =& Folder::get(1);
$oUser =& User::get(1);
$sLocalname = KT_DIR . "/tests/document/dataset1/critique-of-pure-reason.txt";
$sFilename = tempnam("/tmp", "kt_tests_document_add");
copy($sLocalname, $sFilename);
$oDocument =& KTDocumentUtil::add($oFolder, "testquickupload.txt", $oUser, array(
'contents' => new KTFSFileLike($sFilename),
));
if (PEAR::isError($oDocument)) {
print "FAILURE\n";
var_dump($oDocument);
exit(0);
}
if (!file_exists($sFilename)) {
copy($sLocalname, $sFilename);
}
$oDocument =& KTDocumentUtil::add($oFolder, "newtest2.txt", $oUser, array());
if (PEAR::isError($oDocument)) {
print "FAILURE\n";
var_dump($oDocument);
}
$res = KTDocumentUtil::storeContents($oDocument, new KTFSFileLike($sFilename));
var_dump($res);
/*
if (file_exists($sFilename)) {
unlink($sFilename);
}
$oDocument->setStatusID(LIVE);
$oDocument->update();
*/
?>