本文整理汇总了PHP中file_storage::action_update_form方法的典型用法代码示例。如果您正苦于以下问题:PHP file_storage::action_update_form方法的具体用法?PHP file_storage::action_update_form怎么用?PHP file_storage::action_update_form使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类file_storage
的用法示例。
在下文中一共展示了file_storage::action_update_form方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function action_update()
{
log_debug("journal_process", "Executing action_update()");
/*
Start Transaction
*/
$sql_obj = new sql_query();
$sql_obj->trans_begin();
/*
If no ID supplied, create a new journal entry first
*/
if (empty($this->structure["id"])) {
$mode = "create";
if (!$this->action_create()) {
return 0;
}
} else {
$mode = "update";
}
/*
Handle some optional fields
*/
if (!isset($this->structure["content"])) {
$this->structure["content"] = "";
}
if (!isset($this->structure["userid"])) {
// automated system user
$this->structure["userid"] = 0;
}
/*
Update journal record
*/
$sql_obj->string = "UPDATE `journal` SET " . "userid='" . $this->structure["userid"] . "', " . "customid='" . $this->structure["customid"] . "', " . "timestamp='" . $this->structure["timestamp"] . "', " . "title='" . $this->structure["title"] . "', " . "content='" . $this->structure["content"] . "' " . "WHERE id='" . $this->structure["id"] . "' LIMIT 1";
$sql_obj->execute();
/*
If journal entry is a file, upload the data
TODO: this currently only works for form uploads
*/
if ($this->structure["type"] == "file") {
if (isset($_FILES["upload"]["name"])) {
log_write("debug", "journal_process", "Uploading file against journal entry from POST form data");
// output file data
$file_obj = new file_storage();
$file_obj->data["type"] = "journal";
$file_obj->data["customid"] = $this->structure["id"];
if ($file_obj->load_data_bytype()) {
log_debug("journal_process", "Old file exists, will overwrite.");
// unset the title variable - otherwise the action_update_form function will retain the existing title
$file_obj->data["file_name"] = NULL;
} else {
log_debug("journal_process", "No previous file exists, performing clean upload.");
}
// call the upload function
if (!$file_obj->action_update_form("upload")) {
log_write("error", "journal_process", "Unable to upload file for journal entry id " . $this->structure["id"] . "");
}
} else {
// not uploading
log_write("debug", "journal_process", "No file POST data provided, not uploading file to journal - assuming manual DB upload");
}
}
/*
Commit
*/
if (error_check()) {
$sql_obj->trans_rollback();
log_write("error", "journal_process", "An error occured whilst updating the journal.");
return 0;
} else {
$sql_obj->trans_commit();
if ($this->structure["type"] != "event") {
if ($mode == "update") {
log_write("notification", "journal_process", "Journal entry updated successfully.");
} else {
log_write("notification", "journal_process", "New record added to the journal successfully.");
}
}
return 1;
}
return 0;
}
示例2: header
Update the logo file if required
*/
if ($_FILES["COMPANY_LOGO"]["size"] > 1) {
// set file variables
$file_obj->data["type"] = "COMPANY_LOGO";
$file_obj->data["customid"] = "0";
// see if a file already exists
if ($file_obj->load_data_bytype()) {
log_debug("process", "Old file exists, will overwrite.");
} else {
log_debug("process", "No previous file exists, performing clean upload.");
}
// force the filename
$file_obj->data["file_name"] = "company_logo.png";
// call the upload function
if (!$file_obj->action_update_form("COMPANY_LOGO")) {
log_write("error", "process", "Unable to upload company logo");
}
}
/*
Commit
*/
if (error_check()) {
$sql_obj->trans_rollback();
log_write("error", "process", "An error occured whilst updating configuration, no changes have been applied.");
} else {
$sql_obj->trans_commit();
log_write("notification", "process", "Company configuration updated successfully");
}
header("Location: ../index.php?page=admin/config_company.php");
exit(0);