本文整理汇总了PHP中Folder::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::create方法的具体用法?PHP Folder::create怎么用?PHP Folder::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Folder
的用法示例。
在下文中一共展示了Folder::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Initialisation du cache
*/
function __construct()
{
$this->folder = AdminServConfig::$PATH_RESOURCES . 'cache/';
if (!file_exists($this->folder)) {
Folder::create($this->folder);
}
}
示例2: newFile
public function newFile($name, $contents)
{
$file = new File($this->t, $name);
$path = new Folder($file->getPath());
$path->exists() || $path->create();
$file->out()->write($contents);
}
示例3: addShopToFolder
/**
* add shop to folder
*
*/
function addShopToFolder()
{
$name = @$this->request->data['name'];
$shop_id = @$this->request->data['shop_id'];
if (!$shop_id || !$name) {
return $this->responseng('faild to add shop.');
}
$dataFolder = array("user_id" => $this->user_id, "name" => $name, "type_folder" => intval(@$this->request->data['type_folder']));
$ret = $this->FolderUser->save($dataFolder);
$folder_id_old = @$this->request->data["older_folder_id"];
$datashopFolder = array("folder_id" => $ret["FolderUser"]["id"], "shop_id" => $shop_id, "rank" => 1, "status" => NO_MY_FOLDER);
$result = $this->FolderShop->save($datashopFolder);
App::uses('Folder', 'Utility');
$folder = new Folder();
if (!empty($folder_id_old)) {
$oldFolder = $this->FolderUser->findById($folder_id_old);
$newFolder = $ret;
$path = WWW_ROOT . 'shops' . DS . $oldFolder["FolderUser"]["user_id"] . DS . $oldFolder["FolderUser"]["id"] . DS . $shop_id;
$newPath = WWW_ROOT . 'shops' . DS . $newFolder["FolderUser"]["user_id"] . DS . $newFolder["FolderUser"]["id"] . DS . $result["FolderShop"]["shop_id"];
if (is_dir($path)) {
if (!is_dir($newPath)) {
$folder->create($newPath);
}
$folder->copy(array('to' => $newPath, 'from' => $path, 'mode' => 0777));
}
}
if ($result) {
return $this->responseOk();
}
return $this->responseng('can not save data');
}
示例4: upload
public function upload(Model $Model, $arquivo = array(), $altura = 800, $largura = 600, $pasta = null, $nome_arquivo)
{
// App::uses('Vendor', 'wideimage');
App::import('Vendor', 'WideImage', array('file' => 'WideImage' . DS . 'WideImage.php'));
App::uses('Folder', 'Utility');
$ext = array('image/jpg', 'image/jpeg', 'image/pjpeg', 'image/x-jps', 'image/png', 'image/gif');
if ($arquivo['error'] != 0 || $arquivo['size'] == 0) {
return false;
}
$img = WideImage::load($arquivo['tmp_name']);
$folder = new Folder();
$pathinfo = pathinfo($arquivo['name']);
if ($folder->create(WWW_ROOT . 'img' . DS . $pasta . DS)) {
//se conseguiu criar o diretório eu dou permissão
$folder->chmod(WWW_ROOT . 'img' . DS . $pasta . DS, 0755, true);
} else {
return false;
}
$pathinfo['filename'] = strtolower(Inflector::slug($pathinfo['filename'], '-'));
$arquivo['name'] = $nome_arquivo . '.' . $pathinfo['extension'];
$img->saveToFile(WWW_ROOT . 'img' . DS . $pasta . DS . 'original_' . $arquivo['name']);
$img = $img->resize($largura, $altura, 'fill');
$img->saveToFile(WWW_ROOT . 'img' . DS . $pasta . DS . $arquivo['name']);
// debug(WWW_ROOT.'img'.DS.$pasta.DS.$arquivo['name']); die;
return $arquivo['name'];
}
示例5: find
function find($conditions = null, $fields = array(), $order = null, $recursive = null)
{
if ($conditions != 'range') {
return parent::find($conditions, $fields, $order, $recursive);
}
$file = Set::extract($fields, 'file');
if (empty($file)) {
$file = ROOT . DS . APP_DIR . DS . 'plugins/mobileip/config/mobile_ips.yml';
}
if (!file_exists($file)) {
return false;
}
$cacheDir = $this->getCacheDir();
$folder = new Folder($cacheDir);
$folder->create($cacheDir, 0777);
$cacheFile = $this->getCacheFile();
if (file_exists($cacheFile) && $this->_getLastModified($file) <= filemtime($cacheFile)) {
return include $cacheFile;
}
$mobile_ips =& Spyc::YAMLLoad($file);
if (!is_array($mobile_ips)) {
return false;
}
$data = $this->_get_ranges($mobile_ips);
$file = new File($cacheFile, true);
$file->write($data);
$file->close();
return include $cacheFile;
}
示例6: Folder
function save_asset($file)
{
$result['status'] = false;
$this->log('file info: ', 7);
$this->log($file, 7);
$info = $this->fileinfo($file);
if (empty($info['content_type']) || !in_array($info['content_type'], $this->options['valid_types'])) {
$this->log('not saving, invalid filetype...', 7);
$result['message'] = 'Invalid filetype';
return $result;
}
if ($this->save($info)) {
$this->log('saved on line 52', 7);
$folder = new Folder();
if ($folder->create($this->path() . $this->id . DS . 'original')) {
move_uploaded_file($file['tmp_name'], $this->path() . $this->id . DS . 'original' . DS . $info['filename']);
if (in_array($info['content_type'], $this->options['image_types'])) {
if ($this->create_folders($this->id) && $this->process_styles($this->id, $info)) {
$result['message'] = 'files resized and saved';
$result['status'] = true;
}
}
} else {
$result['message'] = "There was a problem creating a folder, check your permissions";
return $result;
}
}
return $result;
}
示例7: __construct
public function __construct()
{
$this->path = STORAGE_DIR . 'Cache/';
if (!is_dir($this->path)) {
\Folder::create($this->path, 0755);
}
\Support::writable($this->path);
}
示例8: admin_export
public function admin_export($id = null)
{
if (!$id) {
$this->notice('invalid');
}
$this->Template->recursive = -1;
$template = $this->Template->read(array('name', 'description', 'author', 'header', 'footer'), $id);
if (empty($template)) {
$this->notice('invalid');
}
$pattern = "/src=[\\\"']?([^\\\"']?.*(png|jpg|gif|jpeg))[\\\"']?/i";
preg_match_all($pattern, $template['Template']['header'], $images);
$path = TMP . 'cache' . DS . 'newsletter' . DS . 'template' . DS . $template['Template']['name'];
$Folder = new Folder($path, 0777);
$slash = $Folder->correctSlashFor($path);
App::import('File');
App::import('Folder');
$File = new File($path . DS . 'template.xml', true, 0777);
$imageFiles = array();
if (!empty($images[1])) {
foreach ($images[1] as $img) {
$img = str_replace('/', $slash, $img);
$img = str_replace('\\', $slash . $slash, $img);
$imageFiles[] = $img;
if (is_file(APP . 'webroot' . $img)) {
$Folder->create(dirname($path . $img), 0777);
$File->path = APP . 'webroot' . $img;
$File->copy(dirname($path . $img) . DS . basename($img));
}
}
}
$xml['template']['name'] = 'Infinitas Newsletter Template';
$xml['template']['generator'] = 'Infinitas Template Generator';
$xml['template']['version'] = $this->version;
$xml['template']['template'] = $template['Template']['name'];
$xml['template']['description'] = $template['Template']['description'];
$xml['template']['author'] = $template['Template']['author'];
$xml['data']['header'] = $template['Template']['header'];
$xml['data']['footer'] = $template['Template']['footer'];
$xml['files']['images'] = $imageFiles;
App::Import('Helper', 'Xml');
$Xml = new XmlHelper();
$File->path = $path . DS . 'template.xml';
$File->write($Xml->serialize($xml));
App::import('Vendor', 'Zip', array('file' => 'zip.php'));
$Zip = new CreateZipFile();
$Zip->zipDirectory($path, null);
$File = new File($path . DS . 'template.zip', true, 0777);
$File->write($Zip->getZippedfile());
$this->view = 'Media';
$params = array('id' => 'template.zip', 'name' => $template['Template']['name'], 'download' => true, 'extension' => 'zip', 'path' => $path . DS);
$this->set($params);
$Folder = new Folder($path);
$Folder->read();
$Folder->delete($path);
}
示例9: extract
/**
* Extract an archive file to a directory.
*
* @param string $archivename The name of the archive file
* @param string $extractdir Directory to unpack into
*
* @return boolean True for success
*
* @since 1.0
* @throws \InvalidArgumentException
*/
public function extract($archivename, $extractdir)
{
$ext = pathinfo($archivename, PATHINFO_EXTENSION);
$path = pathinfo($archivename, PATHINFO_DIRNAME);
$filename = pathinfo($archivename, PATHINFO_FILENAME);
switch ($ext) {
case 'zip':
$result = $this->getAdapter('zip')->extract($archivename, $extractdir);
break;
case 'tar':
$result = $this->getAdapter('tar')->extract($archivename, $extractdir);
break;
case 'tgz':
case 'gz':
case 'gzip':
// This may just be an individual file (e.g. sql script)
$tmpfname = $this->options['tmp_path'] . '/' . uniqid('gzip');
$gzresult = $this->getAdapter('gzip')->extract($archivename, $tmpfname);
if ($gzresult instanceof \Exception) {
@unlink($tmpfname);
return false;
}
if ($ext === 'tgz' || stripos($filename, '.tar') !== false) {
$result = $this->getAdapter('tar')->extract($tmpfname, $extractdir);
} else {
Folder::create($path);
$result = File::copy($tmpfname, $extractdir, null, 0);
}
@unlink($tmpfname);
break;
case 'tbz2':
case 'bz2':
case 'bzip2':
// This may just be an individual file (e.g. sql script)
$tmpfname = $this->options['tmp_path'] . '/' . uniqid('bzip2');
$bzresult = $this->getAdapter('bzip2')->extract($archivename, $tmpfname);
if ($bzresult instanceof \Exception) {
@unlink($tmpfname);
return false;
}
if ($ext === 'tbz2' || stripos($filename, '.tar') !== false) {
$result = $this->getAdapter('tar')->extract($tmpfname, $extractdir);
} else {
Folder::create($path);
$result = File::copy($tmpfname, $extractdir, null, 0);
}
@unlink($tmpfname);
break;
default:
throw new Exception(sprintf('Unknown archive type: %s', $ext));
}
if (!$result || $result instanceof Exception) {
return false;
}
return true;
}
示例10: createTmpFile
/**
* Create temporary file for upload test.
*
* @param string $fileName Temporary file name
* @return void
*/
public function createTmpFile($fileName)
{
//アップロードテストのためのテンポラリファイル生成
$folder = new Folder();
$folder->create(TMP . 'tests' . DS . 'files' . DS . 'tmp');
$file = new File(APP . 'Plugin' . DS . 'Files' . DS . 'Test' . DS . 'Fixture' . DS . $fileName);
$file->copy(TMP . 'tests' . DS . 'files' . DS . 'tmp' . DS . $fileName);
$file->close();
unset($folder, $file);
}
示例11: makeDir
function makeDir($dir)
{
if (!is_dir($dir)) {
$parent_perms = $this->getPerms(dirname($dir));
$f = new Folder();
if ($f->create($dir, octdec($parent_perms))) {
return true;
} else {
if ($parent_perms == '0755') {
if ($f->chmod($dir, 0777) && $f->create($dir)) {
return true;
}
}
}
return false;
} else {
return true;
}
}
示例12: setUp
public function setUp()
{
parent::setUp();
$this->console = new ConsoleOutput();
$this->temp_dir = sys_get_temp_dir() . '/FilesystemDatasourceWorkdir/';
$folder = new Folder();
$folder->create($this->temp_dir);
$this->console->write('<info>Using temporary dir: "' . $this->temp_dir . '"</info>');
$config = array('baseDir' => $this->temp_dir);
$this->datasource = new FilesystemSource($config);
}
示例13: __construct
public function __construct()
{
// Dil doyalarının yer alacağı dizinin belirtiliyor.
$this->appdir = STORAGE_DIR . 'MultiLanguage/';
// Eğer dizin mevcut değilse oluşturulması sağlanıyor.
if (!is_dir($this->appdir)) {
Folder::create($this->appdir, 0777);
}
// Aktif dil dosyasının yolu belirtiliyor.
$this->lang = $this->appdir . getLang() . $this->extension;
}
示例14: __construct
/**
* Apply the cache settings.
*
* @param array $config
*/
public function __construct($config = array())
{
parent::__construct($config);
if (Cache::config('feeds') === false) {
$cachePath = CACHE . 'feeds' . DS;
if (!file_exists($cachePath)) {
$folder = new Folder();
$folder->create($cachePath, 0777);
}
Cache::config('feeds', array('engine' => 'File', 'serialize' => true, 'prefix' => 'feed_', 'path' => $cachePath, 'duration' => '+1 day'));
}
}
示例15: __construct
public function __construct( $request = NULL, $response = NULL ) {
Configure::load('report_manager.bootstrap');
$reportPath = Configure::read('ReportManager.reportPath');
if ( !isset($reportPath) )
$reportPath = 'tmp'.DS.'reports'.DS;
$this->path = $reportPath;
if(!is_dir(APP.$this->path)) {
$folder = new Folder();
$folder->create(APP.$this->path);
}
parent::__construct($request,$response);
}