$folderhash[$foldername] = $id_dest; foreach ($rii as $r) { $foldername = $r->getPathName(); $folderpath = $r->getPath(); $name = $r->getFilename(); if ($r->isDir()) { echo "Creating " . $r->getFilename() . " folder ..... "; try { $res = $soap->createDocmanFolder($hash, $project_id, $folderhash[$folderpath], $r->getFilename(), '', "end"); } catch (Exception $e) { die("This folder doesn't exist in the docman. Check out the id_destination(" . $e->getMessage() . ")" . PHP_EOL); } echo "OK" . PHP_EOL; $folderhash[$foldername] = $res; } elseif ($r->isFile()) { if (uploadAllowed($r->getFilename())) { //remove the extension to the name /*if (substr_count($name, '.') > 0) { $name = substr($r->getFilename(), 0, strrpos($r->getFilename(), '.')); }*/ echo "Uploading " . $name . " ..... "; $fileName = basename($r->getPathname()); $fileSize = filesize($r->getPathname()); $fileType = shell_exec('file -bi "' . escapeshellcmd($r->getPathname()) . '"'); try { $itemId = $soap->createDocmanFile($hash, $project_id, $folderhash[$folderpath], $name, '', 'end', 100, 0, array(), array(), $fileSize, $fileName, $fileType, '', 0, $chunkSize); if ($itemId) { $offset = 0; while ($chunk = getChunk($r->getPathname(), $offset, $chunkSize)) { $soap->appendDocmanFileChunk($hash, $project_id, $itemId, $chunk, $offset, $chunkSize); $offset++;
// Temp file age in seconds switch ($_GET['type']) { case 'image': case 'images': case 'file': case 'files': $targetDir = makeUploadFolder(); $cleanupTargetDir = false; break; } if (isset($_GET['path']) && $_GET['path'] != '') { /* Using same user level as in fileOperations (in lib.php) */ $PIVOTX['session']->minLevel(PIVOTX_UL_ADVANCED); $path = cleanPath($_GET['path']); // Don't ever allow uploading outside the images, templates and db folders. if (!uploadAllowed($path)) { die('{"jsonrpc" : "2.0", "error" : {"code": 104, "message": "Uploading to illegal directory."}, "id" : "id"}'); } $targetDir = stripTrailingSlash($path); $cleanupTargetDir = false; } // 5 minutes execution time @set_time_limit(5 * 60); // usleep(5000); // Get parameters $chunk = isset($_REQUEST["chunk"]) ? $_REQUEST["chunk"] : 0; $chunks = isset($_REQUEST["chunks"]) ? $_REQUEST["chunks"] : 0; $fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : ''; if ($fileName == '' && isset($_FILES['file']['name'])) { $fileName = $_FILES['file']['name']; }