本文整理汇总了PHP中AZLib::uploadDocPath方法的典型用法代码示例。如果您正苦于以下问题:PHP AZLib::uploadDocPath方法的具体用法?PHP AZLib::uploadDocPath怎么用?PHP AZLib::uploadDocPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AZLib
的用法示例。
在下文中一共展示了AZLib::uploadDocPath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: on_submit
function on_submit()
{
$title = Url::get('title');
$url = Url::get('url');
$des = Url::get('des');
if ($des == '<br>') {
$des = $title;
}
$this->checkFormInput("Tên tài liệu", "title", $title, "str", true, '', 1);
if (!$this->errNum) {
$uploadPath = AZLib::uploadDocPath();
//Insert to document
$doc_id = DB::insert('document', array('title' => addslashes($title), 'des' => addslashes($des), 'status' => 1, 'time_c' => TIME_NOW, 'user_c' => User::user_name(), 'time_m' => TIME_NOW, 'user_m' => User::user_name(), 'file_path' => ''));
if ($doc_id) {
if ($url != '') {
DB::update('document', array('file_path' => '', 'url' => $url), "id={$doc_id}");
} elseif (isset($_FILES['file_path']) && $_FILES['file_path']['error'] == 0) {
$ext = strtolower(AZLib::getExtension($_FILES['file_path']['name']));
$file_name = AZLib::safe_title(basename(strtolower($_FILES['file_path']['name']), $ext)) . $ext;
$up_file = $uploadPath . date('Y.m.d_H\\hi.s') . "-{$doc_id}-{$file_name}";
$file_path = str_replace(DATA_PATH . "document/", '', $up_file);
chmod($uploadPath, 0777);
if (!move_uploaded_file($_FILES['file_path']['tmp_name'], $up_file)) {
DB::delete('document', "id={$doc_id}");
$this->setFormError('file_path', "Không upload được file!");
return;
} else {
DB::update('document', array('file_path' => $file_path), "id={$doc_id}");
}
}
Url::redirect_current();
//Url::redirect_current(array('cmd'=>'add'));
} else {
$this->setFormError('name', "Không thêm được tài liệu, hãy thử lại sau!");
}
}
}