本文整理汇总了PHP中FileModel::add方法的典型用法代码示例。如果您正苦于以下问题:PHP FileModel::add方法的具体用法?PHP FileModel::add怎么用?PHP FileModel::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileModel
的用法示例。
在下文中一共展示了FileModel::add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addAction
/**
* 上传
*/
public function addAction()
{
if ($this->_request->isPost()) {
$post = $this->_request->getPost();
$post['uid'] = $this->auths->uid;
$fileData = $_FILES['file'];
$data = $this->file->add($post, $fileData, false);
$this->_redirect($this->view->url(array('action' => 'list')));
}
$this->view->cateId = $this->_getParam('id');
$select = $this->file->cateListSql()->where('cate.allow_upload=1');
$this->view->categories = $this->db->fetchAll($select);
}
示例2: addClicked
public function addClicked(SubmitButton $button)
{
$array = $button->getForm()->getValues();
if ($array['authorId'] == 'true') {
$array['author'] = dibi::query('SELECT authorId FROM authors ORDER BY authorId DESC LIMIT 1')->fetchSingle();
} elseif ($array['author'] == 0) {
$this->flashMessage('Je potřaba vybrat autora!', 'error');
return;
}
unset($array['authorId']);
try {
$array['url'] = Model::createUri($array['title'], $array['author']);
} catch (Exception $e) {
$this->flashMessage('U tohoto autora byla již vložena práce se stejným jménem', 'error');
return;
}
$array['added%sql'] = 'NOW()';
$array['edited%sql'] = 'NOW()';
$array = $this->fixValues($array);
$file = $array['file'];
unset($array['file']);
$id = Model::add($array, 'works');
if ($file != '') {
FileModel::add($id, $_FILES['file']);
}
$s = Environment::getSession('workform');
$s->author = $array['author'];
$s->award = $array['award'];
$s->year = $array['year'];
$s->type = $array['type'];
$this->flashMessage('Práce byla přidána.', 'info');
$this->redirect("this");
}
示例3: POST_indexAction
/**
* 上传文件
* POST /file/
* @method POST_index
* @param key 获取token时返回的key
*/
public function POST_indexAction()
{
if (!Input::post('key', $key, 'filename')) {
$this->response(0, '未收到数据');
return;
}
list(, $userid) = explode('_', $key, 3);
$userid = $this->auth($userid);
$response['status'] = 0;
if (!($name = Cache::get($key))) {
$response['info'] = '文件不存在';
} else {
Cache::del($key);
/*文件名由 t_xxxx,重命名为 f_xxxx*/
$bucket = Config::getSecret('qiniu', 'file');
$uri = $bucket . ':f_' . substr($key, 2);
$file['name'] = $name;
$file['url'] = $uri;
$file['use_id'] = $userid;
if (!File::set($bucket . ':' . $key, $uri)) {
$response['info'] = '文件校验失败';
} elseif (!($fid = FileModel::add($file))) {
$response['info'] = '文件保存失败';
} else {
$response['status'] = 1;
$response['info'] = ['msg' => '保存成功', 'id' => $fid];
}
}
$this->response = $response;
}