本文整理匯總了PHP中f::copy方法的典型用法代碼示例。如果您正苦於以下問題:PHP f::copy方法的具體用法?PHP f::copy怎麽用?PHP f::copy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類f
的用法示例。
在下文中一共展示了f::copy方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setUp
protected function setUp()
{
parent::setUp();
$this->user = $this->createAdmin();
$this->user->login('test');
$this->page = $this->site->children()->create('test', 'test');
f::copy($this->roots->dummy . DS . 'images' . DS . 'forrest.jpg', $this->page->root() . DS . '1.jpg');
f::copy($this->roots->dummy . DS . 'images' . DS . 'forrest.jpg', $this->page->root() . DS . '2.jpg');
}
示例2: copy
/**
* Copies the file to a new location
*
* @param string $to
* @return boolean
*/
public function copy($to)
{
return f::copy($this->root, $to);
}
示例3: testCopy
public function testCopy()
{
$this->assertTrue(f::copy(TEST_ROOT_TMP . DS . 'moved.txt', TEST_ROOT_TMP . DS . 'copied.txt'));
}
示例4: attach
public function attach($file, $filename = null)
{
// if the item has not been stored yet
// throw an exception
if (!$this->exists()) {
throw new Exception('Unstored item');
}
// filename fallback
if (is_null($filename)) {
$filename = basename($file);
}
// sanitize the filename
$filename = f::safeName($filename);
// the item.yaml cannot be overwritten
if ($filename == 'item.yaml') {
throw new Exception('item.yaml is a reserved filename');
}
// files cannot be overwritten
if (file_exists($this->root() . DS . $filename)) {
throw new Exception('The file exists and cannot be overwritten');
}
// attach a remote url
if (v::url($file)) {
$response = remote::get($file);
if ($response->code() < 400) {
if (!f::write($this->root() . DS . $filename, $response->content())) {
throw new Exception('The file could not be saved');
}
} else {
throw new Exception('The file could not be fetched');
}
} else {
if (file_exists($file)) {
if (!f::copy($file, $this->root() . DS . $filename)) {
throw new Exception('The file could not be copied');
}
}
}
}
示例5: copy
protected function copy()
{
// copy the controller template to the controller directory
f::copy($this->template(), $this->file());
}