public function upload($pid, $content, $type) { $postData['pid'] = $pid; $pi = pathinfo($content); // \helpers\Debug::prePrintR($pi); $filename = $pi['filename']; $ext = $pi['extension']; $postData['content'] = ''; // Надо использовать исходное имя файла $postData['type'] = $type; $postData = $this->isValidNodeItem($postData); if ($postData !== false) { $postData['sort'] = $this->getMaxSort($pid) + 1; $f3 = \Base::instance(); $f3->set('postData', $postData); $item =& $this->mapper; $item->reset(); $item->copyFrom('postData'); $item->save(); $path = '../tmp/uploads/' . session_id() . '/' . $content; \helpers\ImageCorrector::getInstance()->correct($path); // -------------------------------------------- $dir = $f3->get('ROOT') . '/uploads/' . $this->slug . '/'; // TODO: Заменить вызовы mkdir на this->mkdir if (!is_dir($dir)) { if (!mkdir($dir, 0777)) { echo $dir . ' making error'; } } $dir .= ceil($pid / 100) . '/'; if (!is_dir($dir)) { mkdir($dir, 0777); } $dir .= $pid . '/'; if (!is_dir($dir)) { mkdir($dir, 0777); } $res = copy($path, $dir . $item->id . '.' . $ext); return $item->id; } return false; }
private function makeDirStructure($id, $tnw) { $dir = \helpers\ImageCorrector::getInstance()->makeDir([$this->tableMeta->get('table'), 'fields', 'tmp', $tnw, ceil($id / 100), $id]); return $dir; }