本文整理汇总了PHP中FileHelper::uploadDocumentFile方法的典型用法代码示例。如果您正苦于以下问题:PHP FileHelper::uploadDocumentFile方法的具体用法?PHP FileHelper::uploadDocumentFile怎么用?PHP FileHelper::uploadDocumentFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileHelper
的用法示例。
在下文中一共展示了FileHelper::uploadDocumentFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleFileFormData
function handleFileFormData($edit_submit = false)
{
global $template, $WebBaseDir, $i18n, $DocumentDir, $ClassDir, $AddIP, $userid, $group_ids;
$apf_files = DB_DataObject::factory('ApfFiles');
if ($edit_submit) {
$apf_files->get($apf_files->escape($_POST['ID']));
$do_action = "updatefilesubmit";
} else {
$do_action = "addfilesubmit";
}
$apf_files->setName(stripslashes(trim($_POST['name'])));
$apf_files->setParent(stripslashes(trim($_POST['parent'])));
$apf_files->setDescription(stripslashes(trim($_POST['description'])));
$apf_files->setMajorRevision(stripslashes(trim($_POST['major_revision'])));
$apf_files->setMinorRevision(stripslashes(trim($_POST['minor_revision'])));
$apf_files->setPassword(stripslashes(trim($_POST['password'])));
$apf_files->setActive(stripslashes(trim($_POST['active'])));
$apf_files->setAccess(stripslashes(trim($_POST['access'])));
$apf_files->setAddIp($AddIP);
$apf_files->setGroupid($group_ids);
$apf_files->setUserid($userid);
$UploadDocumentDir = $DocumentDir . $this->getFolderByPID($_POST['parent']);
if ($_POST['filename_del'] == 'Y') {
unlink($UploadDocumentDir . $_POST['filename_old']);
$apf_files->setFilename("");
$_POST['filename_old'] = "";
}
if ($_POST['upload_temp']) {
$apf_files->setFilename($_POST['upload_temp']);
}
$allow_upload_file = TRUE;
if ($_FILES['filename']['name']) {
require_once $ClassDir . "FileHelper.class.php";
$upload_data = FileHelper::uploadDocumentFile($UploadDocumentDir);
// Var_Dump::display($upload_data);
$allow_upload_file = $upload_data["upload_state"];
if ($allow_upload_file) {
$filenames_arr = $upload_data["upload_msg"];
if ($filename_pic = $filenames_arr['filename']) {
$apf_files->setFilename($filename_pic);
$apf_files->setExt($filenames_arr['exten_name']);
$apf_files->setFSize($filenames_arr['file_size']);
$_POST['upload_temp'] = $filename_pic;
}
} else {
$upload_error_msg = $upload_data["upload_msg"];
}
}
$val = $apf_files->validate();
if ($val === TRUE && $allow_upload_file === TRUE) {
if ($edit_submit) {
$apf_files->setUpdateAt(DB_DataObject_Cast::dateTime());
$apf_files->update();
$this->forward("document/apf_folders/update/" . $_POST['ID'] . "/ok");
} else {
$apf_files->setCreatedAt(DB_DataObject_Cast::dateTime());
$apf_files->insert();
$log_string = $i18n->_("Create") . $i18n->_("File") . "\t{$_POST['name']}";
logFileString($log_string);
$this->forward("document/apf_folders/list/{$_POST['parent']}");
}
} else {
$template->setFile(array("MAIN" => "apf_files_edit.html"));
$template->setBlock("MAIN", "edit_block");
$template->setVar(array("WEBDIR" => $WebBaseDir, "DOACTION" => $do_action));
if (is_array($val)) {
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("FILENAME_ERROR_MSG" => " ↓ {$upload_error_msg} ↓ "));
}
$template->setVar(array("ID" => $_POST['id'], "NAME" => $_POST['name'], "PARENT" => $_POST['parent'], "FILENAME" => $_POST['filename'], "F_SIZE" => $_POST['f_size'], "DESCRIPTION" => $_POST['description'], "CHECKED_OUT" => $_POST['checked_out'], "MAJOR_REVISION" => $_POST['major_revision'], "MINOR_REVISION" => $_POST['minor_revision'], "URL" => $_POST['url'], "PASSWORD" => $_POST['password'], "USERID" => $_POST['userid'], "GROUPID" => $_POST['groupid'], "ACTIVE" => $_POST['active'], "ADD_IP" => $_POST['add_ip'], "CREATED_AT" => $_POST['created_at'], "UPDATE_AT" => $_POST['update_at']));
}
}