Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to copy documents?
#3
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:
PHP Code:
<?php 
$res
= $dest->addDocument($_fileName, '', 0, 'Administrator', '', $_tmpFile, $_originalName, $_fileType, $_mimeType, $_sequence, $reviewers=array(), $approvers=array(),$_reqversion,$version_comment='');

Complete code:


PHP Code:
<?php 
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 Wink
Reply


Messages In This Thread
How to copy documents? - by michbukana - 02-09-2012, 04:11 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)