本文整理汇总了PHP中N2Filesystem::createFolder方法的典型用法代码示例。如果您正苦于以下问题:PHP N2Filesystem::createFolder方法的具体用法?PHP N2Filesystem::createFolder怎么用?PHP N2Filesystem::createFolder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类N2Filesystem
的用法示例。
在下文中一共展示了N2Filesystem::createFolder方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setCurrentPath
protected function setCurrentPath()
{
$this->currentPath = N2Filesystem::getImagesFolder() . NDS . $this->group;
if (!N2Filesystem::existsFolder($this->currentPath)) {
N2Filesystem::createFolder($this->currentPath);
}
}
示例2: clearCurrentGroup
protected function clearCurrentGroup()
{
self::clearGroup($this->group);
if (!N2Filesystem::existsFolder($this->currentPath)) {
N2Filesystem::createFolder($this->currentPath);
}
}
示例3: actionUpload
public function actionUpload()
{
if (defined('N2_IMAGE_UPLOAD_DISABLE')) {
N2Message::error(n2_('You are not allowed to upload!'));
$this->response->error();
}
$this->validateToken();
$root = N2Filesystem::getImagesFolder();
$folder = ltrim(rtrim(N2Request::getVar('path', ''), '/'), '/');
$path = N2Filesystem::realpath($root . '/' . $folder);
if ($path === false || $path == '') {
$folder = preg_replace("/[^A-Za-z0-9]/", '', $folder);
if (empty($folder)) {
N2Message::error(n2_('Folder is missing!'));
$this->response->error();
} else {
N2Filesystem::createFolder($root . '/' . $folder);
$path = N2Filesystem::realpath($root . '/' . $folder);
}
}
$relativePath = $this->relative($path, $root);
if (!$relativePath) {
$relativePath = '';
}
$response = array('path' => $relativePath);
try {
if (isset($_FILES) && isset($_FILES['image']) && isset($_FILES['image']['name'])) {
$info = pathinfo($_FILES['image']['name']);
$fileName = preg_replace('/[^a-zA-Z0-9_-]/', '', $info['filename']);
if (strlen($fileName) == 0) {
$fileName = '';
}
$upload = new N2BulletProof();
$file = $upload->uploadDir($path)->upload($_FILES['image'], $fileName);
$response['name'] = basename($file);
$response['url'] = N2ImageHelper::dynamic(N2Filesystem::pathToAbsoluteURL($file));
}
} catch (Exception $e) {
N2Message::error($e->getMessage());
$this->response->error();
}
$this->response->respond($response);
}
示例4: actionSaveImage
public function actionSaveImage()
{
$this->validateToken();
N2Loader::import('libraries.image.aviary');
$image = N2Request::getVar('aviaryUrl');
$this->validateVariable(!empty($image), 'image');
require_once dirname(__FILE__) . '/Browse.php';
$root = N2Filesystem::getImagesFolder();
$folder = 'aviary';
$path = N2Filesystem::realpath($root . '/' . $folder);
if ($path === false || $path == '') {
N2Filesystem::createFolder($root . '/' . $folder);
$path = N2Filesystem::realpath($root . '/' . $folder);
}
$tmp = tempnam(sys_get_temp_dir(), 'image-');
file_put_contents($tmp, file_get_contents($image));
$src = null;
// Set variables for storage
// fix file filename for query strings
preg_match('/([^\\?]+)\\.(jpe?g|gif|png)\\b/i', $image, $matches);
$file_array['name'] = basename($matches[1]);
$file_array['tmp_name'] = $tmp;
$file_array['size'] = filesize($tmp);
$file_array['error'] = 0;
try {
$fileName = preg_replace('/[^a-zA-Z0-9_-]/', '', $file_array['name']);
$upload = new N2BulletProof();
$file = $upload->uploadDir($path)->upload($file_array, $fileName);
$src = N2ImageHelper::dynamic(N2Filesystem::pathToAbsoluteURL($file));
} catch (Exception $e) {
N2Message::error($e->getMessage());
$this->response->error();
}
if ($src) {
$this->response->respond(array('image' => $src));
} else {
N2Message::error(sprintf(n2_('Unexpected error: %s'), $image));
$this->response->error();
}
}
示例5: recursive_extract
function recursive_extract($files, $targetFolder)
{
foreach ($files as $fileName => $file) {
if (is_array($file)) {
if (N2Filesystem::createFolder($targetFolder . $fileName . '/')) {
$this->recursive_extract($file, $targetFolder . $fileName . '/');
} else {
return false;
}
} else {
if (!N2Filesystem::createFile($targetFolder . $fileName, $file)) {
return false;
}
}
}
return true;
}
示例6: create
public function create($saveAsFile = false)
{
$this->backup = new N2SmartSliderBackup();
$slidersModel = new N2SmartsliderSlidersModel();
if ($this->backup->slider = $slidersModel->get($this->sliderId)) {
$this->backup->slider['params'] = new N2Data($this->backup->slider['params'], true);
$slidesModel = new N2SmartsliderSlidesModel();
$this->backup->slides = $slidesModel->getAll($this->backup->slider['id']);
if (empty($this->backup->slider['type'])) {
$this->backup->slider['type'] = 'simple';
}
$class = 'N2SSPluginType' . $this->backup->slider['type'];
N2Loader::importPath(call_user_func(array($class, "getPath")) . NDS . 'backup');
$class = 'N2SmartSliderBackup' . $this->backup->slider['type'];
call_user_func_array(array($class, 'export'), array($this, $this->backup->slider));
$enabledWidgets = array();
$plugins = array();
N2Plugin::callPlugin('sswidget', 'onWidgetList', array(&$plugins));
$params = $this->backup->slider['params'];
foreach ($plugins as $k => $v) {
$widget = $params->get('widget' . $k);
if ($widget && $widget != 'disabled') {
$enabledWidgets[$k] = $widget;
}
}
foreach ($enabledWidgets as $k => $v) {
$class = 'N2SSPluginWidget' . $k . $v;
if (class_exists($class, false)) {
$params->fillDefault(call_user_func(array($class, 'getDefaults')));
call_user_func_array(array($class, 'prepareExport'), array($this, &$params));
} else {
unset($enabledWidgets);
}
}
for ($i = 0; $i < count($this->backup->slides); $i++) {
$slide = $this->backup->slides[$i];
self::addImage($slide['thumbnail']);
$slide['params'] = new N2Data($slide['params'], true);
self::addImage($slide['params']->get('backgroundImage'));
self::addLightbox($slide['params']->get('link'));
N2SmartSliderLayer::prepareExport($this, $slide['slide']);
if (!empty($slide['generator_id'])) {
N2Loader::import("models.generator", "smartslider");
$generatorModel = new N2SmartsliderGeneratorModel();
$this->backup->generators[] = $generatorModel->get($slide['generator_id']);
}
}
$zip = new N2ZipFile();
$this->images = array_unique($this->images);
$this->visuals = array_unique($this->visuals);
foreach ($this->images as $image) {
$this->backup->NextendImageManager_ImageData[$image] = N2ImageManager::getImageData($image, true);
if ($this->backup->NextendImageManager_ImageData[$image]) {
self::addImage($this->backup->NextendImageManager_ImageData[$image]['tablet']['image']);
self::addImage($this->backup->NextendImageManager_ImageData[$image]['mobile']['image']);
} else {
unset($this->backup->NextendImageManager_ImageData[$image]);
}
}
$this->images = array_unique($this->images);
$usedNames = array();
foreach ($this->images as $image) {
$file = N2ImageHelper::fixed($image, true);
if (N2Filesystem::fileexists($file)) {
$fileName = strtolower(basename($file));
while (in_array($fileName, $usedNames)) {
$fileName = $this->uniqueCounter . $fileName;
$this->uniqueCounter++;
}
$usedNames[] = $fileName;
$this->backup->imageTranslation[$image] = $fileName;
$zip->addFile(file_get_contents($file), 'images/' . $fileName);
}
}
foreach ($this->visuals as $visual) {
$this->backup->visuals[] = N2StorageSectionAdmin::getById($visual);
}
$zip->addFile(serialize($this->backup), 'data');
if (!$saveAsFile) {
ob_end_clean();
header('Content-disposition: attachment; filename=' . preg_replace('/[^a-zA-Z0-9_-]/', '', $this->backup->slider['title']) . '.ss3');
header('Content-type: application/zip');
echo $zip->file();
n2_exit(true);
} else {
$file = preg_replace('/[^a-zA-Z0-9_-]/', '', $this->backup->slider['title']) . '.ss3';
$folder = N2Platform::getPublicDir();
$folder .= '/export/';
if (!N2Filesystem::existsFolder($folder)) {
N2Filesystem::createFolder($folder);
}
N2Filesystem::createFile($folder . $file, $zip->file());
}
}
}