本文整理汇总了PHP中FileHelper::createCategoryDir方法的典型用法代码示例。如果您正苦于以下问题:PHP FileHelper::createCategoryDir方法的具体用法?PHP FileHelper::createCategoryDir怎么用?PHP FileHelper::createCategoryDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileHelper
的用法示例。
在下文中一共展示了FileHelper::createCategoryDir方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uploadFile
function uploadFile($CategoryDir)
{
global $ClassDir, $UploadDir, $AllowUploadFilesType, $MaxFileSize;
require_once 'HTTP/Upload.php';
require_once $ClassDir . "FileHelper.class.php";
if (!file_exists($UploadDir)) {
mkdir($UploadDir, 0755);
}
$upload = new http_upload();
// $file = $upload->getFiles($TagName);
$files = $upload->getFiles();
$new_name = array();
foreach ($files as $file) {
$file->setValidExtensions($AllowUploadFilesType, 'accept');
$allow_upload_file = TRUE;
if (PEAR::isError($file)) {
$allow_upload_file = FALSE;
$upload_error_msg = $file->getMessage();
}
if ($file->getProp("size") > $MaxFileSize) {
$allow_upload_file = FALSE;
$upload_error_msg = "Upload file too large";
} else {
if ($file->isValid()) {
$file->setName('uniq');
$current_date = FileHelper::createCategoryDir($UploadDir, $CategoryDir);
$date_image_dir = $UploadDir . $current_date;
$dest_name = $file->moveTo($date_image_dir);
if (PEAR::isError($dest_name)) {
$allow_upload_file = FALSE;
$upload_error_msg = $dest_name->getMessage();
} else {
$real = $file->getProp('real');
$new_name[$file->getProp('form_name')] = $current_date . $dest_name;
}
} elseif ($file->isError()) {
$allow_upload_file = FALSE;
$upload_error_msg = $file->errorMsg();
}
}
}
$data["upload_state"] = $allow_upload_file;
$data["upload_msg"] = $allow_upload_file ? $new_name : $upload_error_msg;
return $data;
}
示例2: handleFormData
function handleFormData($edit_submit = false)
{
global $template, $WebBaseDir, $PhpbbDir, $i18n, $luadmin, $ClassDir, $AllowUploadFilesType, $UploadDir;
$apf_users = DB_DataObject::factory('ApfUsers');
if ($edit_submit) {
$apf_users->get($apf_users->escape($_POST['ID']));
$do_action = "updatesubmit";
} else {
$do_action = "addsubmit";
}
$apf_users->setUserName(stripslashes(trim($_POST['user_name'])));
$apf_users->setGender(stripslashes(trim($_POST['gender'])));
$apf_users->setAddrees(stripslashes(trim($_POST['addrees'])));
$apf_users->setPhone(stripslashes(trim($_POST['phone'])));
$apf_users->setEmail(stripslashes(trim($_POST['email'])));
$apf_users->setPhoto(stripslashes(trim($_POST['photo'])));
$apf_users->setRoleId(stripslashes(trim($_POST['role_id'])));
$apf_users->setActive(stripslashes(trim($_POST['active'])));
$apf_users->setAddIp(stripslashes(trim($_POST['add_ip'])));
$apf_users->setCreatedAt(stripslashes(trim($_POST['created_at'])));
$apf_users->setUpdateAt(stripslashes(trim($_POST['update_at'])));
if ($_POST['photo_del'] == 'Y') {
unlink($UploadDir . $_POST['photo_old']);
$apf_users->setPhoto("");
$_POST['photo_old'] = "";
}
$allow_upload_file = TRUE;
if ($_FILES['photo']['name']) {
require_once 'HTTP/Upload.php';
require_once $ClassDir . "FileHelper.class.php";
$upload = new http_upload();
$file = $upload->getFiles('photo');
$file->setValidExtensions($AllowUploadFilesType, 'accept');
if (PEAR::isError($file)) {
$allow_upload_file = FALSE;
$upload_error_msg = $file->getMessage();
}
if ($file->isValid()) {
$file->setName('uniq');
$current_date = FileHelper::createCategoryDir($UploadDir, "users");
$date_photo_dir = $UploadDir . $current_date;
$dest_name = $file->moveTo($date_photo_dir);
if (PEAR::isError($dest_name)) {
$allow_upload_file = FALSE;
$upload_error_msg = $dest_name->getMessage();
} else {
$real = $file->getProp('real');
$apf_users->setPhoto($current_date . $dest_name);
}
} elseif ($file->isError()) {
$allow_upload_file = FALSE;
$upload_error_msg = $file->errorMsg();
}
}
$val = $apf_users->validate();
// Var_Dump($val);
if ($val === TRUE && $allow_upload_file === TRUE) {
if ($edit_submit) {
$apf_users->setUpdateAt(DB_DataObject_Cast::dateTime());
$apf_users->update();
$password = stripslashes(trim($_POST['user_pwd'])) ? stripslashes(trim($_POST['user_pwd'])) : stripslashes(trim($_POST['old_password']));
if (stripslashes(trim($_POST['user_pwd']))) {
$data = array('handle' => stripslashes(trim($_POST['user_name'])), 'passwd' => $password);
$updated = $luadmin->updateUser($data, $_POST['ID']);
}
$this->forward("users/apf_users/update/" . $_POST['ID'] . "/ok");
} else {
$data = array('handle' => stripslashes(trim($_POST['user_name'])), 'passwd' => stripslashes(trim($_POST['user_pwd'])), 'perm_type' => 1);
$user_id = $luadmin->addUser($data);
$apf_users->get($apf_users->escape($user_id));
// $apf_users->debugLevel(4);
$apf_users->update();
include_once $PhpbbDir . '/hook.php';
$phpbb_action = 'insert';
$phpbb_user['user_id'] = $user_id;
// $uid变量是您要整合的系统中用户ID变量,根据系统不同自行修改,下同
$phpbb_user['username'] = stripslashes(trim($_POST['user_name']));
// 用户名
$phpbb_user['user_password'] = md5(stripslashes(trim($_POST['user_pwd'])));
// 密码,注意必须是已经经过md5加密的密码
$phpbb_user['user_email'] = stripslashes(trim($_POST['email']));
// email
phpbb_user($phpbb_action, $phpbb_user);
$this->forward("users/apf_users/");
}
} else {
$template->setFile(array("MAIN" => "apf_users_edit.html"));
$template->setBlock("MAIN", "edit_block");
$template->setVar(array("WEBDIR" => $WebBaseDir, "DOACTION" => $do_action));
foreach ($val as $k => $v) {
if ($v == false) {
$template->setVar(array(strtoupper($k) . "_ERROR_MSG" => " ↓ " . $i18n->_("Please check here") . " ↓ "));
}
}
if ($allow_upload_file !== TRUE) {
$template->setVar(array("PHOTO_ERROR_MSG" => " ↓ {$upload_error_msg} ↓ "));
}
$template->setVar(array("ID" => $_POST['id'], "USER_NAME" => $_POST['user_name'], "USER_PWD" => $_POST['user_pwd'], "GENDER" => $_POST['gender'], "ADDREES" => $_POST['addrees'], "PHONE" => $_POST['phone'], "EMAIL" => $_POST['email'], "PHOTO" => $_POST['photo'], "ROLE_ID" => $_POST['role_id'], "ACTIVE" => $_POST['active'], "ADD_IP" => $_POST['add_ip'], "CREATED_AT" => $_POST['created_at'], "UPDATE_AT" => $_POST['update_at']));
}
}
示例3: executeImportsubmit
function executeImportsubmit()
{
global $ClassDir, $AllowUploadFilesType, $UploadDir;
$import_file_name = "";
if ($_FILES['sourcefile']['name']) {
require_once 'HTTP/Upload.php';
require_once $ClassDir . "FileHelper.class.php";
$upload = new http_upload();
$file = $upload->getFiles('sourcefile');
$file->setValidExtensions($AllowUploadFilesType, 'accept');
if (PEAR::isError($file)) {
$allow_upload_file = FALSE;
$upload_error_msg = $file->getMessage();
}
if ($file->isValid()) {
$file->setName('uniq');
$current_date = FileHelper::createCategoryDir($UploadDir, "import");
$date_photo_dir = $UploadDir . $current_date;
$dest_name = $file->moveTo($date_photo_dir);
if (PEAR::isError($dest_name)) {
$allow_upload_file = FALSE;
$upload_error_msg = $dest_name->getMessage();
} else {
$real = $file->getProp('real');
$import_file_name = $UploadDir . $current_date . $dest_name;
}
} elseif ($file->isError()) {
$allow_upload_file = FALSE;
$upload_error_msg = $file->errorMsg();
}
}
if (file_exists($import_file_name)) {
switch (strtolower($_POST['what'])) {
case 'excel':
$this->importExcel($import_file_name);
break;
}
}
}