本文整理汇总了PHP中Cake\Filesystem\Folder::inCakePath方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::inCakePath方法的具体用法?PHP Folder::inCakePath怎么用?PHP Folder::inCakePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Filesystem\Folder
的用法示例。
在下文中一共展示了Folder::inCakePath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upload
/**
* This function is used to uplodad file in /uploads/YEAR/MONTH directory
* and to create Content record contextually.
*
*
* @param type $inputfile
* @param string $destfile
* @return boolean
*/
public function upload($inputfile, $destfile = null)
{
if (strlen(trim($inputfile['name'])) === 0) {
return FALSE;
}
$filename = strtolower($inputfile['name']);
$sourcefile = $inputfile['tmp_name'];
$file = new \Cake\Filesystem\File($sourcefile, true, 0775);
$CONTENT_YEAR = date('Y');
$CONTENT_MONTH = date('m');
$UPLOAD_DIR = $this->path;
$folder_dest = new Folder($UPLOAD_DIR);
if (!$folder_dest->inCakePath($folder_dest->pwd() . DS . $CONTENT_YEAR)) {
$folder_dest->create($folder_dest->pwd() . DS . $CONTENT_YEAR);
}
$folder_dest->cd($CONTENT_YEAR);
if (!$folder_dest->inCakePath($folder_dest->pwd() . DS . $CONTENT_MONTH)) {
$folder_dest->create($folder_dest->pwd() . DS . $CONTENT_MONTH);
}
$folder_dest->cd($CONTENT_MONTH);
$path = DS . $CONTENT_YEAR . DS . $CONTENT_MONTH . DS;
$permittedFilename = $this->getPermittedFilename($UPLOAD_DIR . $path, $filename);
$destfile = $folder_dest->pwd() . DS . $permittedFilename;
if ($file->copy($destfile, true)) {
return $path . $permittedFilename;
} else {
return FALSE;
}
}
示例2: testInCakePath
/**
* testInCakePath method
*
* @return void
*/
public function testInCakePath()
{
$Folder = new Folder();
$Folder->cd(ROOT);
$path = 'C:\\path\\to\\file';
$result = $Folder->inCakePath($path);
$this->assertFalse($result);
$path = ROOT;
$Folder->cd(ROOT);
$result = $Folder->inCakePath($path);
$this->assertFalse($result);
$path = DS . 'config';
$Folder->cd(ROOT . DS . 'config');
$result = $Folder->inCakePath($path);
$this->assertTrue($result);
}