当前位置: 首页>>代码示例>>PHP>>正文


PHP file::save方法代码示例

本文整理汇总了PHP中file::save方法的典型用法代码示例。如果您正苦于以下问题:PHP file::save方法的具体用法?PHP file::save怎么用?PHP file::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在file的用法示例。


在下文中一共展示了file::save方法的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();
 }
开发者ID:shihab-92,项目名称:votting-system,代码行数:23,代码来源:profileController.php

示例2: save

 function save($data)
 {
     //如果缓存目录不存在则创建
     if (!$this->is_exist(false)) {
         file::folder($this->save_dir);
     }
     if ($this->ext == 'php') {
         $data = '<?php' . "\r\n" . 'return ' . var_export($data, true) . ';';
     }
     if ($this->ext == 'js') {
         $data = json_encode($data);
     }
     if ($this->ext == 'ini') {
         $data = fun::arr_ini($data);
     }
     if ($this->ext == 'xml') {
         $data = fun::xml($data);
     }
     if (is_array($data) && $this->ext == 'txt') {
         $data = serialize($data);
     }
     return file::save($this->file_name, $data);
 }
开发者ID:art-youth,项目名称:framework,代码行数:23,代码来源:cache.php

示例3: createNewObject

function createNewObject($object_type, $post_vars, $system_data_classes, $object_save = 0)
{
    if (!$object_type) {
        return false;
    }
    if (!in_array($object_type, $system_data_classes)) {
        return false;
    }
    switch ($object_type) {
        case "page":
            $object = new page("new page");
            $object->update_document_props($post_vars);
            if ($object_save == 1) {
                $object->createContent();
                $object->save();
            }
            break;
        case "process":
            $object = new process("new process");
            $object->update_document_props($post_vars);
            $object->update_design_props($post_vars);
            if ($object_save == 1) {
                $object->save();
            }
            break;
        case "section":
            $object = new section("new section");
            $object->update_document_props($post_vars);
            if ($object_save == 1) {
                $object->createContent();
                $object->save();
            }
            break;
        case "image":
            $object = new image("new image");
            $object->update_document_props($post_vars);
            if ($object_save == 1) {
                $object->save();
            }
            break;
        case "file":
            $object = new file("new file");
            $object->update_document_props($post_vars);
            if ($object_save == 1) {
                $object->save();
            }
            break;
        default:
            break;
    }
    return $object;
}
开发者ID:raphael-betemps,项目名称:reservoirlog-php,代码行数:52,代码来源:bases.php

示例4: change_password

 public function change_password($id = null)
 {
     if (!is_null($id) && isset($_POST['new_password'])) {
         $file = new file();
         $file->find($id);
         $file->password = $_POST['new_password'];
         $file->save();
         $this->session->flash($this->l10n->__("La clave de acceso ha sido cambiada"));
         $this->redirect("files");
     }
 }
开发者ID:ravenlp,项目名称:CodiceCMS,代码行数:11,代码来源:files_controller.php

示例5: html

 static function html($url, $file_name, $dir = '')
 {
     $save_dir = self::is_exist('html', $dir);
     $data = file_get_contents($url);
     return file::save($save_dir . $file_name, $data);
 }
开发者ID:art-youth,项目名称:framework,代码行数:6,代码来源:create.php

示例6: register_upload

 public static function register_upload($tmp_name, $target_name, $parent, $mime = NULL, $move_uploaded_file = false)
 {
     global $website;
     global $user;
     global $DB;
     $file = NULL;
     if ($move_uploaded_file) {
         $uploaded_file_temp = uniqid('upload-');
         move_uploaded_file($tmp_name, NAVIGATE_PRIVATE . '/' . $website->id . '/files/' . $uploaded_file_temp);
         $tmp_name = $uploaded_file_temp;
     }
     if (strpos($tmp_name, '/') === 0) {
         $tmp_file_path = $tmp_name;
     } else {
         $tmp_file_path = NAVIGATE_PRIVATE . '/' . $website->id . '/files/' . $tmp_name;
     }
     if (file_exists($tmp_file_path)) {
         if (empty($mime)) {
             $mime = file::getMime($target_name, $tmp_file_path);
         }
         $target_name = rawurldecode($target_name);
         // check if the parent folder given is valid in the current website
         if ($parent > 0) {
             $DB->query('SELECT id FROM nv_files WHERE website = ' . $website->id . ' AND id = ' . $parent);
             $rs = $DB->result('id');
             if (empty($rs) || $rs[0] != $parent) {
                 // parent folder invalid, put file in the root folder
                 $parent = 0;
             }
         }
         $file = new file();
         $file->id = 0;
         $file->website = $website->id;
         $file->mime = $mime[0];
         $file->type = $mime[1];
         $file->parent = intval($parent);
         $file->name = $target_name;
         $file->size = filesize($tmp_file_path);
         if ($file->type == 'image') {
             $dimensions = file::image_dimensions($tmp_file_path);
             $file->width = $dimensions['width'];
             $file->height = $dimensions['height'];
         }
         $file->date_added = core_time();
         $file->uploaded_by = empty($user->id) ? '0' : $user->id;
         $file->permission = 0;
         $file->enabled = 1;
         $file->save();
         rename($tmp_file_path, NAVIGATE_PRIVATE . '/' . $website->id . '/files/' . $file->id);
         if ($file->type == 'image') {
             $file->resize_uploaded_image();
         }
     }
     return $file;
 }
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:55,代码来源:file.class.php

示例7: mail

 static function mail($info)
 {
     $file = dc_log_log . 'mail/' . date('y-m') . '.log';
     $info = '[' . date('d H:i:s') . '] ' . $info . "\n";
     file::save($file, $info, 'a+');
 }
开发者ID:art-youth,项目名称:framework,代码行数:6,代码来源:log.php

示例8: markAnswered

 function markAnswered($msg)
 {
     file::save("data/answered", $msg->message_id . "\n", true);
 }
开发者ID:rivetweb,项目名称:old-python-generators,代码行数:4,代码来源:MailGrabber.php

示例9: sfValidatorFile

//------------------------------------------------------------
$t->diag('File');
$t->diag('File::__toString()');
$t->is((string) $file1, 'dummy_file');
//------------------------------------------------------------
$t->diag('File::getImageFormat()');
$t->is($file1->getImageFormat(), 'png');
$t->is($file2->getImageFormat(), 'jpg');
$t->is($file3->getImageFormat(), false);
//------------------------------------------------------------
$t->diag('File::isImage()');
$t->is($file1->isImage(), true);
$t->is($file2->isImage(), true);
$t->is($file3->isImage(), false);
//------------------------------------------------------------
$t->diag('File::setFromValidatedFile()');
// require
new sfValidatorFile();
$validated = new sfValidatedFile('test.txt', 'text/plain', $tmpDir . '/test.txt', strlen($content));
$newFile = new file();
$newFile->setFromValidatedFile($validated);
$t->is((string) $newFile->getOriginalFilename(), 'test.txt');
//------------------------------------------------------------
$t->diag('File::getFilesize()');
$newFile->save();
$t->is($newFile->getFilesize(), 22, 'The "file.file_size" is stored.');
//-----------------------------------------------------------
$t->diag('->delete()');
$file3->delete();
$t->ok(!Doctrine::getTable('File')->find(3), 'The parent "File" record is removed.');
$t->ok(!Doctrine::getTable('FileBin')->find(3), 'The related "FileBin" record is removed.');
开发者ID:te-koyama,项目名称:openpne,代码行数:31,代码来源:FileTest.php

示例10: makeCategory

 function makeCategory($config, $subcategory)
 {
     print "Make subcategory {$subcategory['id']} page...\n";
     if (!is_dir($outputdir = "{$config->outputdir}/{$subcategory['folder']}")) {
         mkdir($outputdir);
     }
     $item = DB_DataObject::factory("item");
     $categDays = $item->getDays();
     $pager =& Pager::factory(array("mode" => "Jumping", "perPage" => $config->daynum, "delta" => 10, "itemData" => $categDays, "append" => false, "path" => "../", "fileName" => "{$subcategory['folder']}/index%d.html"));
     for ($i = 1; $i <= $pager->numPages(); $i++) {
         $tpl = new template();
         $tpl->load("templates/category.html", true, true);
         $tpl->setv("category_name", $subcategory["name"]);
         PagesGenerator::getCategories($tpl, "../");
         $data = $pager->getPageData($i);
         $links = $pager->getLinks($i);
         $tpl->setBlock("pages");
         $tpl->setv("pages", $links["all"]);
         foreach ($data as $day) {
             $res = $item->getItemsForDayCateg($subcategory["id"], $day[0], $config->itemnum);
             $res1 = $item->getItemsForDayCateg($subcategory["id"], $day[0], $config->itemnum, true);
             if (sizeof($res) == 0 && sizeof($res1) == 0) {
                 continue;
             }
             $tpl->setBlock("forday");
             $tpl->setv("date", date("Y-m-d", strtotime($day[0])));
             if (sizeof($res) > 0) {
                 foreach ($res as $row) {
                     $tpl->setBlock("rows");
                     $tpl->setv($row);
                     $tpl->parseBlock();
                 }
             }
             if (sizeof($res1) > 0) {
                 $numthumbs = 0;
                 foreach ($res1 as $row) {
                     $tpl->setBlock("thumb");
                     $tpl->setv($row);
                     $tpl->parseBlock();
                     if (++$numthumbs >= $config->numthumbs) {
                         $tpl->parse("rowthumbs");
                         $numthumbs = 0;
                     }
                 }
             }
             $tpl->parse("forday");
         }
         file::save("{$config->outputdir}/{$subcategory['folder']}/index{$i}.html", $tpl->get());
     }
 }
开发者ID:rivetweb,项目名称:old-python-generators,代码行数:50,代码来源:PagesGenerator.php

示例11: foreach

            if ('add' == $v) {
                //添加页
                $tr = $tr == 'tr' ? 'tr2' : 'tr';
                foreach ($_POST[$v] as $key => $val) {
                    $fields .= "<tr class='{$tr} h30'>\n<td  class='ltit'>{$_POST['field'][$key]}</td>\n<td><input name='{$key}' type='text'></td>\n</tr>\n";
                }
                $str = str_replace(array('__table__', '__ds_table__', '__fields__'), array($table, $ds_table, $fields), $str);
            } else {
                if ('edit' == $v) {
                    //编辑页
                    $tr = $tr == 'tr' ? 'tr2' : 'tr';
                    foreach ($_POST[$v] as $key => $val) {
                        $fields .= "<tr class='{$tr} h30'>\n<td  class='ltit'>{$_POST['field'][$key]}</td>\n<td><input name='{$key}' value=\"{\$row['{$key}']}\" type='text'></td>\n</tr>\n";
                    }
                    $str = str_replace(array('__table__', '__ds_table__', '__fields__'), array($table, $ds_table, $fields), $str);
                }
            }
        }
        file::save($mod, $str);
    }
}
/** 显示所有的数据表 **/
foreach ($db->query('show tables') as $row) {
    $tables[] = $row[0];
}
$table = in_array($table, $tables) ? $table : $tables[0];
/** 显示一个表中的所有字段 */
foreach ($db->query('show full COLUMNS from ' . $table) as $row) {
    $rows[] = $row;
}
include template::inc('tools/index.php');
开发者ID:robinhunan,项目名称:coolphp,代码行数:31,代码来源:index.php

示例12: 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();
//.........这里部分代码省略.........
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:101,代码来源:files.php

示例13: save

 function save($params)
 {
     $json = new Services_JSON();
     file::save("data/config.ini", $json->encode(array("itemnum" => $params["itemnum"], "daynum" => $params["daynum"], "email" => $params["email"], "emailpassword" => $params["emailpassword"], "emailserver" => $params["emailserver"], "outputdir" => $params["outputdir"], "numthumbs" => $params["numthumbs"], "logemail" => $params["logemail"])));
     print $json->encode(array("error" => false));
 }
开发者ID:rivetweb,项目名称:old-python-generators,代码行数:6,代码来源:configs_controller.php


注:本文中的file::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。