02-10-2012, 03:45 PM
Thanks for the answer,
I try to use the Folder::addDocument function but an error ocurred. I don't know how to use this function, param $dest is the folder to add the new copy file and param $document, the file to copy.
$_tmpFile value is incorrect.
In the function call I write:
Complete code:
Excuse me for my english
I try to use the Folder::addDocument function but an error ocurred. I don't know how to use this function, param $dest is the folder to add the new copy file and param $document, the file to copy.
$_tmpFile value is incorrect.
In the function call I write:
PHP Code:
$res = $dest->addDocument($_fileName, '', 0, 'Administrator', '', $_tmpFile, $_originalName, $_fileType, $_mimeType, $_sequence, $reviewers=array(), $approvers=array(),$_reqversion,$version_comment='');
Complete code:
PHP Code:
function copyDocument($document,$dest) {
if (file_exists($dms->contentDir.$document->getDir())) {
$handle = opendir($dms->contentDir.$document->getDir());
while ($entry = readdir($handle) ) {
if (is_dir($dms->contentDir.$document->getDir().$entry)) continue;
else{
$folder_size += filesize($dms->contentDir.$document->getDir().$entry);
}
}
closedir($handle);
}
// Get document to copy properties
$latestContent = $document->getLatestContent();
$_fileName = $document->getName();
$_fileType = $latestContent->getFileType();
$_mimeType = $latestContent->getMimeType();
$_originalName = $latestContent->getOriginalFileName();
$_sequence = $document->getSequence();
$_reqversion = $latestContent->getVersion();
$_tmpFile = $latestContent->getFolderPathPlain(); // I don't know how to get the tmpFile ????
// Copy only photos (jpg,gif,png)
if($_fileType == ".jpg" || $_fileType == ".gif" || $_fileType == '.png'){
$res = $dest->addDocument($_fileName, '', 0, 'Administrator', '', $_tmpFile, $_originalName, $_fileType, $_mimeType, $_sequence, $reviewers=array(), $approvers=array(),$_reqversion,$version_comment='');
}
print "<li>";
print "<li>".$document->getName().' ** archivo copiado correctamente'.$document->getID();
print "</li>";
}
Excuse me for my english
