本文整理汇总了PHP中Lib::file方法的典型用法代码示例。如果您正苦于以下问题:PHP Lib::file方法的具体用法?PHP Lib::file怎么用?PHP Lib::file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lib
的用法示例。
在下文中一共展示了Lib::file方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: attach
public function attach($key, $file)
{
$fileObject = Lib::file($file['tmp_name'], $file['name']);
$copiedFile = $fileObject->copy(Config::getBasePath() . '/' . Config::$attachmentFolder, $key . '-' . $file['name']);
$attachmentTable = Lib::table('comment_attachment');
$attachmentTable->link($this);
$attachmentTable->filename = $copiedFile->filename;
$attachmentTable->name = $file['name'];
$attachmentTable->store();
}
示例2: copy
public function copy($target, $filename = '')
{
if (empty($filename)) {
$filename = $this->filename;
}
if (!file_exists($target)) {
mkdir($target, 0777, true);
}
if (!copy($this->path, $target . '/' . $filename)) {
return false;
}
return Lib::file($target . '/' . $filename, $filename);
}
示例3: save
public function save()
{
$keys = array('project', 'content', 'url', 'category');
if (!Req::haspost($keys)) {
return $this->fail('Insufficient data.');
}
$identifier = Lib::cookie(Lib::hash(Config::$userkey));
$user = Lib::table('user');
$isLoggedIn = !empty($identifier) && $user->load(array('identifier' => $identifier));
if (!$isLoggedIn) {
return $this->fail('You are not authorized.');
}
$post = Req::post($keys);
extract($post);
$projectTable = Lib::table('project');
if (!$projectTable->load(array('name' => $project))) {
return $this->fail('No such project.');
}
$reportTable = Lib::table('report');
$reportTable->link($projectTable);
$reportTable->link($user);
$reportTable->content = $content;
$reportTable->category_id = $category;
$reportTable->url = $url;
$reportTable->store();
/*
'screenshot-63cg2rb5v47snhfr' =>
array (size=5)
'name' => string '2013-09-01 17.14.14.jpg' (length=23)
'type' => string 'image/jpeg' (length=10)
'tmp_name' => string '/private/var/tmp/phpZmeqEX' (length=26)
'error' => int 0
'size' => int 134583
*/
$files = Req::file();
if (!empty($files)) {
foreach ($files as $key => $file) {
$fileObject = Lib::file($file['tmp_name'], $file['name']);
$copiedFile = $fileObject->copy(Config::getBasePath() . '/' . Config::$screenshotFolder, $fileObject->generateTemporaryFilename($key . '-'));
$screenshotTable = Lib::table('screenshot');
$screenshotTable->link($reportTable);
$screenshotTable->filename = $copiedFile->filename;
$screenshotTable->store();
}
}
return $this->success();
}