本文整理汇总了PHP中file::update方法的典型用法代码示例。如果您正苦于以下问题:PHP file::update方法的具体用法?PHP file::update怎么用?PHP file::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类file
的用法示例。
在下文中一共展示了file::update方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: picture_update
public function picture_update()
{
$validator = Validator::make(Input::all(), file::$rules);
if ($validator->fails()) {
Session::flash('error', 'uploaded file is not valid');
return Redirect::back()->withInput()->withErrors($validator->messages());
}
$data = file::where('user_id', '=', Auth::user()->id)->pluck('path');
$file = Input::file('image');
$extension = $file->getClientOriginalExtension();
$filename = Auth::user()->id . '.' . $extension;
$file->move('uploads', $filename);
$path = '../uploads/' . $filename;
$picture = new file();
$picture->user_id = Auth::user()->id;
$picture->path = $path;
if ($data == null) {
$picture->save();
} else {
$picture->update();
}
return Redirect::back();
}
示例2: exponent_lang_loadFile
$i18n = exponent_lang_loadFile('modules/importer/importers/usercsv/mapper.php');
//Get the post data for future massaging
$post = $_POST;
//Check to make sure the user filled out the required input.
if (!is_numeric($_POST["rowstart"])) {
unset($post['rowstart']);
$post['_formError'] = $i18n['need_number'];
exponent_sessions_set("last_POST", $post);
header("Location: " . $_SERVER['HTTP_REFERER']);
exit('Redirecting...');
}
//Get the temp directory to put the uploaded file
$directory = "modules/importer/importers/usercsv/tmp";
//Get the file save it to the temp directory
if ($_FILES["upload"]["error"] == UPLOAD_ERR_OK) {
$file = file::update("upload", $directory, null, time() . "_" . $_FILES['upload']['name']);
if ($file == null) {
switch ($_FILES["upload"]["error"]) {
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
$post['_formError'] = $i18n['err_file_toolarge'];
break;
case UPLOAD_ERR_PARTIAL:
$post['_formError'] = $i18n['err_file_partial'];
break;
case UPLOAD_ERR_NO_FILE:
$post['_formError'] = $i18n['err_file_none'];
break;
default:
$post['_formError'] = $i18n['err_file_unknown'];
break;
示例3: pathos_core_makeLocation
# General Public License along with Exponent; if
# not, write to:
#
# Free Software Foundation, Inc.,
# 59 Temple Place,
# Suite 330,
# Boston, MA 02111-1307 USA
#
# $Id: upload_standalone.php,v 1.1 2005/05/04 19:11:32 filetreefrog Exp $
##################################################
include_once '../../../pathos.php';
$collection = null;
if (isset($_POST['collection_id'])) {
$collection = $db->selectObject('file_collection', 'id=' . $_POST['collection_id']);
} else {
$collection->id = 0;
$collection->name = 'Uncategorized Files';
$collection->description = 'Theses files have not been categorized yet,';
}
$loc = pathos_core_makeLocation('filemanagermodule');
// PERM CHECK
$file = file::update('file', 'files', null);
if (is_object($file)) {
$file->name = $_POST['name'];
$file->collection_id = $collection->id;
$file_id = $db->insertObject($file, 'file');
header('Location: ' . URL_FULL . 'modules/filemanagermodule/actions/picker.php?id=' . $collection->id . '&highlight_file=' . $file_id);
} else {
echo $file;
}
// END PERM CHECK
示例4: unserialize
if ($_POST['rank'] > $image->rank) {
// New rank is after the current rank. Item moved down
$db->decrement('imagegallery_image', 'rank', 1, 'gallery_id=' . $image->gallery_id . ' AND rank < ' . $_POST['rank'] . ' AND rank >= ' . $image->rank);
$_POST['rank']--;
}
}
// Rank didn't change
$image->rank = $_POST['rank'];
} else {
$image->rank = $_POST['rank'];
$db->increment('imagegallery_image', 'rank', 1, "gallery_id=" . $image->gallery_id . " AND rank >= " . $_POST['rank'] . " AND rank < " . $image->rank);
}
$loc = unserialize($gallery->location_data);
if (!isset($image->id)) {
$dir = 'files/imagegallerymodule/' . $loc->src . '/gallery' . $gallery->id;
$file = file::update('file', $dir, null);
if (is_object($file)) {
$image->file_id = $db->insertObject($file, 'file');
} else {
// If file::update() returns a non-object, it should be a string. That string is the error message.
$post = $_POST;
$post['_formError'] = $file;
pathos_sessions_set('last_POST', $post);
header('Location: ' . $_SERVER['HTTP_REFERER']);
}
}
if (isset($image->id)) {
$db->updateObject($image, 'imagegallery_image');
} else {
$image->posted = time();
$db->insertObject($image, "imagegallery_image");
示例5: or
# Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# GPL: http://www.gnu.org/licenses/gpl.txt
#
##################################################
if (!defined('EXPONENT')) {
exit('');
}
$resource = $db->selectObject('resourceitem', 'id=' . intval($_POST['id']));
if ($resource) {
$loc = unserialize($resource->location_data);
$iloc = exponent_core_makeLocation($loc->mod, $loc->src, $resource->id);
if (exponent_permissions_check('edit', $loc) || exponent_permissions_check('edit', $iloc)) {
$directory = 'files/resourcesmodule/' . $loc->src;
$file = file::update('file', $directory, null, time() . '_' . $_FILES['file']['name']);
if (is_object($file)) {
$id = $db->insertObject($file, 'file');
$resource->file_id = $id;
$resource->editor = $user->id;
$resource->edited = time();
if (isset($_POST['checkin']) && ($user->is_acting_admin == 1 || $user->id == $resource->flock_owner)) {
$resource->flock_owner = 0;
}
if (!defined('SYS_WORKFLOW')) {
include_once BASE . 'subsystems/workflow.php';
}
exponent_workflow_post($resource, 'resourceitem', $loc);
unset($_SESSION['resource_cache']);
} else {
// If file::update() returns a non-object, it should be a string. That string is the error message.
示例6: serialize
$item->location_data = serialize($loc);
if (!isset($item->id)) {
if (!defined('SYS_FILES')) {
include_once BASE . 'subsystems/files.php';
}
$directory = 'files/imagemanagermodule/' . $loc->src;
$fname = null;
if (exponent_files_uploadDestinationFileExists($directory, 'file')) {
// Auto-uniqify Logic here
$fileinfo = pathinfo($_FILES['file']['name']);
$fileinfo['extension'] = '.' . $fileinfo['extension'];
do {
$fname = basename($fileinfo['basename'], $fileinfo['extension']) . uniqid('') . $fileinfo['extension'];
} while (file_exists(BASE . $directory . '/' . $fname));
}
$file = file::update('file', $directory, null, $fname);
if (is_object($file)) {
$item->file_id = $db->insertObject($file, 'file');
// Make thumbnail?
$db->insertObject($item, 'imagemanageritem');
exponent_flow_redirect();
} else {
// If file::update() returns a non-object, it should be a string. That string is the error message.
$post = $_POST;
$post['_formError'] = $file;
exponent_sessions_set('last_POST', $post);
header('Location: ' . $_SERVER['HTTP_REFERER']);
}
}
} else {
$db->updateObject($item, 'imagemanageritem');
示例7: exit
exit('');
}
$banner = null;
if (isset($_POST['id'])) {
$banner = $db->selectObject('banner_ad', 'id=' . intval($_POST['id']));
$loc = unserialize($banner->location_data);
}
if (exponent_permissions_check('manage', $loc)) {
$filenew = $_FILES['file']['tmp_name'];
$fileup = getimagesize($filenew);
if ($fileup[2] > 0 && $fileup[1] > 0) {
$banner = banner_ad::update($_POST, $banner);
$banner->location_data = serialize($loc);
if (!isset($banner->file_id)) {
$directory = 'files/BannerModule/' . $loc->src;
$file = file::update('file', $directory, null);
if (is_object($file)) {
$banner->file_id = $db->insertObject($file, 'file');
$db->insertObject($banner, 'banner_ad');
} else {
// If file::update() returns a non-object, it should be a string. That string is the error message.
$post = $_POST;
$post['_formError'] = $file;
exponent_sessions_set('last_POST', $post);
header('Location: ' . $_SERVER['HTTP_REFERER']);
}
} else {
$db->updateObject($banner, 'banner_ad');
}
exponent_flow_redirect();
} else {
示例8: exit
# for more details.
#
# You should have received a copy of the GNU
# General Public License along with Exponent; if
# not, write to:
#
# Free Software Foundation, Inc.,
# 59 Temple Place,
# Suite 330,
# Boston, MA 02111-1307 USA
#
# $Id: upload_image.php,v 1.1 2005/04/18 01:27:23 filetreefrog Exp $
##################################################
if (!defined('PATHOS')) {
exit('');
}
// PERM CHECK
$image = imageworkshop_image::update($_POST, null);
$file = file::update('file', 'files/imageworkshopmodule/' . $loc->src, null, uniqid('') . '_' . $_FILES['file']['name']);
$image->file_id = $db->insertObject($file, 'file');
$image->is_upload = 1;
$image->location_data = serialize($loc);
$image->rank = $db->max('imageworkshop_image', 'rank', 'location_data', "location_data='" . $image->location_data . "'");
if ($image->rank == null) {
$image->rank = 0;
} else {
$image->rank++;
}
$db->insertObject($image, 'imageworkshop_image');
pathos_flow_redirect();
// END PERM CHECK
示例9: exit
#
# $Id: save_upload.php,v 1.5 2005/02/19 00:32:32 filetreefrog Exp $
##################################################
//GREP:HARDCODEDTEXT
if (!defined("PATHOS")) {
exit("");
}
if (pathos_permissions_check("create", $loc)) {
$t = null;
if (isset($_POST['id'])) {
$t = $db->selectObject("htmltemplate", "id=" . $_POST['id']);
}
$t = htmltemplate::update($_POST, $t);
$directory = "files/htmltemplatemodule";
if ($_FILES["file"]["error"] == UPLOAD_ERR_OK) {
$file = file::update("file", $directory, null);
if ($file != null) {
$t->body = file_get_contents(BASE . $directory . "/" . $file->filename);
unlink(BASE . $directory . "/" . $file->filename);
if (isset($t->id)) {
$db->updateObject($t, "htmltemplate");
} else {
$db->insertObject($t, "htmltemplate");
}
pathos_flow_redirect();
}
} else {
$post = $_POST;
pathos_lang_loadDictionary('modules', 'filemanager');
switch ($_FILES["file"]["error"]) {
case UPLOAD_ERR_INI_SIZE:
示例10: or
# it and/or modify it under the terms of the GNU
# General Public License as published by the Free
# Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# GPL: http://www.gnu.org/licenses/gpl.txt
#
##################################################
if (!defined('EXPONENT')) {
exit('');
}
$collection = null;
if (isset($_POST['collection_id'])) {
$collection = $db->selectObject('file_collection', 'id=' . intval($_POST['collection_id']));
}
$loc = exponent_core_makeLocation('FileManagerModule');
if ($collection) {
// PERM CHECK
$file = file::update('file', 'files.php', null);
if (is_object($file)) {
$file->name = $_POST['name'];
$file->collection_id = $collection->id;
$db->insertObject($file, 'file');
exponent_flow_redirect();
} else {
echo $file;
}
// END PERM CHECK
} else {
echo SITE_404_HTML;
}
示例11: exit
#
# Free Software Foundation, Inc.,
# 59 Temple Place,
# Suite 330,
# Boston, MA 02111-1307 USA
#
# $Id: save_upload.php,v 1.1 2005/05/04 19:11:32 filetreefrog Exp $
##################################################
if (!defined('PATHOS')) {
exit('');
}
$collection = null;
if (isset($_POST['collection_id'])) {
$collection = $db->selectObject('file_collection', 'id=' . $_POST['collection_id']);
}
$loc = pathos_core_makeLocation('filemanagermodule');
if ($collection) {
// PERM CHECK
$file = file::update($_POST['file'], 'files', 'files.php', null);
if (is_object($file)) {
$file->name = $_POST['name'];
$file->collection_id = $collection->id;
$db->insertObject($file, $_POST['name']);
pathos_flow_redirect();
} else {
echo $file;
}
// END PERM CHECK
} else {
echo SITE_404_HTML;
}
示例12: serialize
if ($item == null && pathos_permissions_check("post", $loc) || $item != null && pathos_permissions_check("edit", $loc)) {
$item = imagemanageritem::update($_POST, $item);
$item->location_data = serialize($loc);
if (!isset($item->id)) {
if (!defined("SYS_FILES")) {
require_once BASE . "subsystems/files.php";
}
$directory = "files/imagemanagermodule/" . $loc->src;
$fname = null;
if (pathos_files_uploadDestinationFileExists($directory, "file")) {
// Auto-uniqify Logic here
$fileinfo = pathinfo($_FILES['file']['name']);
$fileinfo['extension'] = "." . $fileinfo['extension'];
do {
$fname = basename($fileinfo['basename'], $fileinfo['extension']) . uniqid("") . $fileinfo['extension'];
} while (file_exists(BASE . $directory . "/{$fname}"));
}
$file = file::update("file", $directory, null, $fname);
if ($file != null) {
$item->file_id = $db->insertObject($file, "file");
// Make thumbnail?
$db->insertObject($item, "imagemanageritem");
pathos_flow_redirect();
}
} else {
$db->updateObject($item, "imagemanageritem");
pathos_flow_redirect();
}
} else {
echo SITE_403_HTML;
}
示例13: run
function run()
{
global $user;
global $layout;
global $DB;
global $website;
$out = '';
$item = new file();
switch ($_REQUEST['act']) {
case 1:
// json retrieval & operations
// json retrieval & operations
case "json":
if ($_REQUEST['op'] == 'upload') {
$tmp_name = $_REQUEST['tmp_name'];
if ($tmp_name == "{{BASE64}}") {
$tmp_name = base64_encode($_REQUEST['name']);
}
$file = file::register_upload($tmp_name, $_REQUEST['name'], $_REQUEST['parent']);
if (!empty($file)) {
echo json_encode(array('id' => $file->id, 'name' => $file->name));
} else {
echo json_encode(false);
}
}
switch ($_REQUEST['op']) {
case 'create_folder':
file::create_folder($_REQUEST['name'], $_REQUEST['mime'], $_REQUEST['parent']);
echo json_encode(true);
break;
case 'edit_folder':
$f = new file();
$f->load(intval($_REQUEST['id']));
$f->name = $_REQUEST['name'];
$f->mime = $_REQUEST['mime'];
$ok = $f->save();
echo json_encode($ok);
break;
case 'edit_file':
$f = new file();
$f->load(intval($_REQUEST['id']));
$f->name = $_REQUEST['name'];
$ok = $f->save();
echo json_encode($ok);
break;
case 'duplicate_file':
//error_reporting(~0);
//ini_set('display_errors', 1);
$status = false;
$f = new file();
$f->load(intval($_REQUEST['id']));
$f->id = 0;
$f->insert();
if (!empty($f->id)) {
$done = copy(NAVIGATE_PRIVATE . '/' . $website->id . '/files/' . intval($_REQUEST['id']), NAVIGATE_PRIVATE . '/' . $website->id . '/files/' . $f->id);
$status = "true";
if (!$done) {
$f->delete();
$status = t(56, "Unexpected error");
}
}
echo $status;
break;
case 'move':
if (is_array($_REQUEST['item'])) {
$ok = true;
for ($i = 0; $i < count($_REQUEST['item']); $i++) {
unset($item);
$item = new file();
$item->load($_REQUEST['item'][$i]);
$item->parent = $_REQUEST['folder'];
$ok = $ok & $item->update();
}
echo json_encode($ok ? true : false);
} else {
$item->load($_REQUEST['item']);
$item->parent = $_REQUEST['folder'];
echo json_encode($item->update());
}
break;
case 'delete':
try {
$item->load($_REQUEST['id']);
$status = $item->delete();
echo json_encode($status);
} catch (Exception $e) {
echo $e->getMessage();
}
break;
case 'permissions':
$item->load($_REQUEST['id']);
if (!empty($_POST)) {
$item->access = intval($_POST['access']);
$item->permission = intval($_POST['permission']);
$item->enabled = intval($_POST['enabled']);
$item->groups = $_POST['groups'];
if ($item->access < 3) {
$item->groups = array();
}
$status = $item->save();
//.........这里部分代码省略.........