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


PHP Upload::default_directory方法代码示例

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


在下文中一共展示了Upload::default_directory方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: action_save

 public function action_save()
 {
     if ($_POST && $_FILES) {
         $imageChanged = false;
         $data = (object) $this->sanitize($_POST);
         $update = false;
         if ($data->id == "") {
             $editorial = ORM::factory("editorial");
         } else {
             $editorial = ORM::factory("editorial", $data->id);
         }
         if (in_array($_FILES['image']['type'], $this->allowed)) {
             Upload::$default_directory = Kohana::config('myshot.basePath');
             if ($stage_path = Upload::save($_FILES['image'])) {
                 $imageChanged = true;
                 Library_Akamai::factory()->addToDir($stage_path, 'editorials');
             }
         }
         $editorial->title = $data->title;
         $editorial->image = $imageChanged ? Kohana::config('myshot.cdn') . 'editorials/' . basename($stage_path) : $editorial->image;
         $editorial->image_alt = $data->image_alt;
         $editorial->link = $data->link;
         $editorial->link_text = $data->link_text;
         $editorial->text = $data->text;
         $editorial->save();
         Message::set(Message::SUCCESS, $update ? "You have sucessfully updated the editorial." : "You have sucessfully added the editorial.");
     }
     Request::instance()->redirect('admin/editorials');
 }
开发者ID:natgeo,项目名称:kids-myshot,代码行数:29,代码来源:editorials.php

示例2: post_upload

 public function post_upload()
 {
     $file = $this->param('file', array(), TRUE);
     if (!is_dir(BACKUP_PLUGIN_FOLDER)) {
         throw HTTP_API_Exception::factory(API::ERROR_UNKNOWN, 'Folder (:folder) not exist!', array(':folder' => BACKUP_PLUGIN_FOLDER));
     }
     if (!is_writable(BACKUP_PLUGIN_FOLDER)) {
         throw HTTP_API_Exception::factory(API::ERROR_UNKNOWN, 'Folder (:folder) must be writable!', array(':folder' => BACKUP_PLUGIN_FOLDER));
     }
     # Проверяем на расширение
     if (!Upload::type($file, array('sql', 'zip'))) {
         throw HTTP_API_Exception::factory(API::ERROR_UNKNOWN, 'Bad format of file!');
     }
     $ext = pathinfo($file['name'], PATHINFO_EXTENSION);
     # Имя файла
     $filename = 'uploaded-' . date('YmdHis') . '-' . $file['name'];
     Upload::$default_directory = BACKUP_PLUGIN_FOLDER;
     # Cохраняем оригинал и продолжаем работать, если ок:
     if ($file = Upload::save($file, $filename, NULL, 0777)) {
         $this->response(__('File :filename successfully uploaded', array(':filename' => $filename)));
         Kohana::$log->add(Log::ALERT, 'Backup file :filename uploaded by :user', array(':filename' => $filename))->write();
     }
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:23,代码来源:backup.php

示例3: editAward

 private function editAward($award)
 {
     $data = Arr::merge($this->sanitize($_POST), $_FILES);
     $award->title = $data['name'];
     $award->desc = $data['description'];
     if (isset($data['photo']) && $data['photo']['name'] != "") {
         Upload::$default_directory = Kohana::config('myshot.basePath');
         if ($stage_path = Upload::save($data['photo'])) {
             foreach ($award->_images as $image) {
                 $name = (string) $image->type->name;
                 if ($image->type->name == self::FULL) {
                     $path_info = pathinfo($stage_path);
                     $savedAt = $path_info['dirname'] . '/' . $path_info['filename'] . '.' . $path_info['extension'];
                     Library_Akamai::factory()->addToDir($savedAt, Kohana::config('akamai.honordir'));
                     $image->path = $this->webpath($stage_path);
                 } else {
                     $image->path = $this->webPath($this->resizeHonor($stage_path, ImageTypes::types()->{$name}->size));
                 }
                 $image->save();
             }
         }
     }
     $award->save();
 }
开发者ID:natgeo,项目名称:kids-myshot,代码行数:24,代码来源:awards.php

示例4:

 */
Kohana::modules(array('user' => MODPATH . 'user', 'database' => MODPATH . 'database', 'image' => MODPATH . 'image', 'captcha' => MODPATH . 'captcha', 'minion' => MODPATH . 'minion'));
/**
 * Attach the file write to logging.
 * Multiple writers are supported.
 */
if (Kohana::$environment !== Kohana::DEVELOPMENT and Kohana::$environment !== Kohana::STAGING) {
    Kohana::$log->attach(new Log_File(APPPATH . 'logs'), LOG_INFO);
} else {
    Kohana::$log->attach(new Log_File(APPPATH . 'logs'));
}
/**
 * Default path for uploads directory.
 * Path are referenced by a relative or absolute path.
 */
Upload::$default_directory = APPPATH . 'uploads';
/**
 * Set the routes
 *
 * Each route must have a minimum of a name,
 * a URI and a set of defaults for the URI.
 *
 * Example:
 * ~~~
 *	Route::set('frontend/page', 'page(/<action>)')
 *		->defaults(array(
 *			'controller' => 'page',
 *			'action' => 'view',
 *	));
 * ~~~
 *
开发者ID:MenZil-Team,项目名称:cms,代码行数:31,代码来源:bootstrap.php

示例5: upload

 /**
  * Upload new file
  * @param array $file
  * @param string $name
  * @return string
  */
 protected function upload($file, $name = NULL)
 {
     if (empty($file['name'])) {
         return $name;
     }
     Upload::$default_directory = 'media/data/' . $this->model->object_plural();
     if (!file_exists('media/data/' . $this->model->object_plural())) {
         mkdir('media/data/' . $this->model->object_plural(), 0777);
     }
     return str_replace(DOCROOT . 'media/data/' . $this->model->object_plural() . '/', '', Upload::save($file, $name));
 }
开发者ID:raku,项目名称:MorCMS,代码行数:17,代码来源:file.php

示例6: check_photo

 private function check_photo()
 {
     // Photo validation
     $data = Arr::merge($_POST, $_FILES);
     $photo = ORM::factory('photo');
     $validate = $photo->validate_create($data);
     $tag_errors = $this->validate_tags();
     // Check both!
     if ($validate->check() and empty($errors)) {
         Upload::$default_directory = Kohana::config('myshot.basePath');
         if ($stage_path = Upload::save($data['photo'])) {
             $img = Image::factory($stage_path);
             $photo->user_id = $this->user->id;
             $photo->original = basename($stage_path);
             $photo->file_type = $data['photo']['type'];
             $photo->name = Arr::get($data, 'name');
             $photo->caption = Arr::get($data, 'caption');
             $photo->category_id = Arr::get($data, 'category');
             $photo->width = $img->width;
             $photo->height = $img->height;
             $photo->save();
             $large_image = $this->create_large($stage_path, $photo);
             $croppable = $this->create_medium($large_image, $photo);
             $crop = new Controller_Canvas_Photos(Request::instance());
             $crop->crop_small($croppable);
             $crop->crop_thumbnail($croppable);
             $tags = new Controller_Tags(Request::instance());
             $tags->add_tags($_POST, $photo);
             //log the photo upload action
             $tagstr = "";
             foreach ($photo->tags->find_all() as $tag) {
                 $tagstr .= $tag->name . ",";
             }
             $gameUser = Helper_Game::getUser($this->user->id);
             $gameItem = $gameUser->getItem($photo->id);
             $gameItem->addData('tags', $tagstr);
             $gameItem->addData('category', $photo->category->name);
             $gameItem->addData('type', 'image');
             Helper_Game::logEvent(Helper_Game::IMG_UPLOAD, $this->user->id, $photo->id, array('photo' => $photo->id, 'tags' => $tagstr, 'category' => $photo->category->name));
             Request::instance()->redirect('canvas/photos/' . $photo->id);
         }
     } else {
         Message::set(Message::ERROR, Arr::merge($validate->errors('photo'), $tag_errors));
     }
 }
开发者ID:natgeo,项目名称:kids-myshot,代码行数:45,代码来源:photos.php

示例7:

Kohana::init(array('base_url' => '/', 'index_file' => false));
/**
 * Attach the file write to logging. Multiple writers are supported.
 */
Kohana::$log->attach(new Log_File(APPPATH . 'logs'));
/**
 * Attach a file reader to config. Multiple readers are supported.
 */
Kohana::$config->attach(new Config_File());
/**
 * Enable modules. Modules are referenced by a relative or absolute path.
 */
Kohana::modules(array('auth' => MODPATH . 'auth', 'cache' => MODPATH . 'cache', 'database' => MODPATH . 'database', 'image' => MODPATH . 'image', 'orm' => MODPATH . 'orm'));
/**
 * Cookie Salt
 * @see  http://kohanaframework.org/3.3/guide/kohana/cookies
 * 
 * If you have not defined a cookie salt in your Cookie class then
 * uncomment the line below and define a preferrably long salt.
 */
Cookie::$salt = '';
/**
 * Directory for uploads
 */
Upload::$default_directory = DOCROOT . 'public' . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR;
/**
 * Set the routes. Each route must have a minimum of a name, a URI and a set of
 * defaults for the URI.
 */
Route::set('admin', 'admin(<controller>(/<action>(/<id>)))')->defaults(array('controller' => 'admin', 'action' => 'index'));
Route::set('default', '(<controller>(/<action>(/<id>)))')->defaults(array('controller' => 'main', 'action' => 'index'));
开发者ID:alex-bro,项目名称:olgabro.repo,代码行数:31,代码来源:bootstrap.php

示例8: check_avatar

 private function check_avatar()
 {
     Upload::$default_directory = Kohana::config('myshot.basePath');
     $files = Validate::factory($_FILES);
     $files->rules('photo', array('Upload::valid' => NULL, 'Upload::type' => array(array('jpg', 'png', 'gif')), 'Upload::size' => array('5M'), 'Upload::not_empty' => NULL));
     if ($files->check()) {
         if ($stage_path = Upload::save($files['photo'])) {
             $this->remove_avatar();
             $avatar = ORM::factory('avatar')->where('user_id', '=', $this->user->id);
             $avatar->user_id = $this->user->id;
             $avatar->original = basename($stage_path);
             $avatar->file_type = $files['photo']['type'];
             $avatar->save();
             $croppable = $this->create_large($stage_path, $avatar);
             $crop = new Controller_Canvas_Avatar(Request::instance());
             $crop->crop_medium($croppable);
             $crop->crop_thumbnail($croppable);
             $gameUser = Helper_Game::getUser($this->user->id);
             $gameItem = $gameUser->getItem($avatar->id);
             $gameItem->addData('type', 'avatar');
             Helper_Game::logEvent(Helper_Game::ADD_AVATAR, $this->user->id, $avatar->id, array('avatar_id' => $avatar->id));
             Request::instance()->redirect('canvas/avatar');
         }
     } else {
         // Validation failed son!
         Message::set(Message::ERROR, $files->errors('avatar'));
     }
 }
开发者ID:natgeo,项目名称:kids-myshot,代码行数:28,代码来源:account.php

示例9: action_upload

 public function action_upload()
 {
     $this->auto_render = FALSE;
     $errors = array();
     # Проверяем файл
     if (!isset($_FILES['file'])) {
         $this->go_back();
     }
     $file = $_FILES['file'];
     if (!is_dir(BACKUP_PLUGIN_FOLDER)) {
         $errors[] = __('Folder (:folder) not exist!', array(':folder' => BACKUP_PLUGIN_FOLDER));
     }
     if (!is_writable(BACKUP_PLUGIN_FOLDER)) {
         $errors[] = __('Folder (:folder) must be writable!', array(':folder' => BACKUP_PLUGIN_FOLDER));
     }
     # Проверяем на пустоту
     if (!Upload::not_empty($file)) {
         $errors[] = __('File is not attached!');
     }
     # Проверяем на расширение
     if (!Upload::type($file, array('sql', 'zip'))) {
         $errors[] = __('Bad format of file!');
     }
     if (!empty($errors)) {
         Messages::errors($errors);
         $this->go_back();
     }
     $ext = pathinfo($file['name'], PATHINFO_EXTENSION);
     # Имя файла
     $filename = 'uploaded-' . date('YmdHis') . '-' . $file['name'];
     Upload::$default_directory = BACKUP_PLUGIN_FOLDER;
     # Cохраняем оригинал и продолжаем работать, если ок:
     if ($file = Upload::save($file, $filename, NULL, 0777)) {
         Messages::success(__('File :filename uploaded successfully', array(':filename' => $filename)));
         Kohana::$log->add(Log::ALERT, 'Backup file :filename uploaded by :user', array(':filename' => $filename))->write();
         $this->go_back();
     }
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:38,代码来源:backup.php

示例10: editBadge

 private function editBadge($badge)
 {
     $data = Arr::merge($this->sanitize($_POST), $_FILES);
     $badge->title = $data['name'];
     $badge->desc = $data['description'];
     if (isset($data['startstop'])) {
         $badge->available = $data['startyear'] . "-" . $data['startmonth'] . "-" . $data['startday'];
         $badge->expiration = $data['endyear'] . "-" . $data['endmonth'] . "-" . $data['endday'];
     } else {
         $badge->data->available = null;
         $badge->data->expiration = null;
     }
     //Delete unused rules
     foreach ($badge->rules as $rule) {
         $stillHere = false;
         for ($i = 0; $i < count($data['rule_id']); ++$i) {
             if ($data['rule_id'][$i] == $rule->id) {
                 $stillHere = true;
                 break;
             }
         }
         if (!$stillHere) {
             $rule->delete();
         }
     }
     //Add new ones and update existing
     for ($i = 0; $i < count($data['rule_name']); ++$i) {
         $event = ORM::factory('game_Event', $data['event'][$i]);
         if ($data['rule_id'][$i] == 0) {
             $rule = $badge->createRule($data['rule_name'][$i], $event, $data['event_amount'][$i]);
         } else {
             $rule = ORM::factory("game_Rule", $data['rule_id'][$i]);
             $rule->name = $data['rule_name'][$i];
             $rule->event_id = $event->id;
             $rule->amount = $data['event_amount'][$i];
         }
         if ($data['data_key'][$i] != '' && $data['data_key'][$i] != 'key name') {
             $rule->log_info_name = $data['data_key'][$i];
             $rule->operator = $data['data_method'][$i];
             $rule->contains_data = $data['data_content'][$i];
         }
         $rule->save();
     }
     if (isset($data['photo']) && $data['photo']['name'] != "") {
         Upload::$default_directory = Kohana::config('myshot.basePath');
         if ($stage_path = Upload::save($data['photo'])) {
             foreach ($badge->_images as $image) {
                 $name = (string) $image->type->name;
                 if ($image->type->name == self::FULL) {
                     $path_info = pathinfo($stage_path);
                     $savedAt = $path_info['dirname'] . '/' . $path_info['filename'] . '.' . $path_info['extension'];
                     Library_Akamai::factory()->addToDir($savedAt, Kohana::config('akamai.honordir'));
                     $image->path = $this->webpath($stage_path);
                 } else {
                     $image->path = $this->webPath($this->resizeHonor($stage_path, ImageTypes::types()->{$name}->size));
                 }
                 $image->save();
             }
         }
     }
     $badge->save();
 }
开发者ID:natgeo,项目名称:kids-myshot,代码行数:62,代码来源:badges.php

示例11: action_uploadmarkimg

 public function action_uploadmarkimg()
 {
     $dir = SLINEDATA . '/mark';
     //水印图片存储目录
     if (!is_dir($dir)) {
         mkdir($dir);
     }
     $path_info = pathinfo($_FILES['Filedata']['name']);
     $filename = 'mark.' . $path_info['extension'];
     Upload::$default_directory = $dir;
     //默认保存文件夹
     Upload::$remove_spaces = true;
     //上传文件删除空格
     $file = $_FILES['Filedata'];
     $arr = array();
     if (Upload::valid($file) && Upload::size($file, "500KB") && Upload::type($file, array('jpg', 'png', 'gif'))) {
         if (Upload::save($file, $filename)) {
             $arr['success'] = 'true';
             $arr['bigpic'] = $GLOBALS['$cfg_basehost'] . '/data/mark/' . $filename;
         }
     } else {
         $arr['success'] = 'false';
         $arr['msg'] = '上传失败,请检查图片大小,图片格式.';
     }
     echo json_encode($arr);
 }
开发者ID:lz1988,项目名称:stourwebcms,代码行数:26,代码来源:uploader.php

示例12: action_destination


//.........这里部分代码省略.........
                             unset($data->istopnav);
                             unset($data->pinyin);
                             unset($data->pid);
                             unset($data->kindtype);
                             unset($data->litpic);
                             unset($data->piclist);
                             unset($data->issel);
                             unset($data->shownum);
                             unset($data->templet);
                             unset($data->weburl);
                             foreach ($data as $k => $v) {
                                 $dest->{$k} = $v;
                             }
                             $dest->displayorder = $data->displayorder;
                         }
                     }
                     $dest->displayorder = empty($dest->displayorder) ? 9999 : $dest->displayorder;
                     $dest->save();
                     if ($dest->saved()) {
                         echo json_encode(array('success' => true));
                     } else {
                         echo json_encode(array('success' => false));
                     }
                 } else {
                     if ($action == 'uploadfile') {
                         $file = $_FILES['Filedata'];
                         $rootpath = realpath(DOCROOT . '../');
                         $dir = $rootpath . "/uploads/main/" . date('Ymd');
                         if (!file_exists($dir)) {
                             mkdir($dir);
                         }
                         $path_info = pathinfo($_FILES['Filedata']['name']);
                         $filename = date('His') . '.' . $path_info['extension'];
                         Upload::$default_directory = $dir;
                         //默认保存文件夹
                         Upload::$remove_spaces = true;
                         //上传文件删除空格
                         if (Upload::valid($file)) {
                             if (Upload::size($file, "1M")) {
                                 if (Upload::type($file, array('jpg', 'png', 'gif'))) {
                                     if (Upload::save($file, $filename)) {
                                         $newfile = $dir . '/' . $filename;
                                         Image::factory($newfile)->resize(600, 400, Image::AUTO)->save($newfile);
                                         echo substr(substr($newfile, strpos($dir, '/uploads') - 1), 1);
                                     } else {
                                         echo "error_no";
                                     }
                                 } else {
                                     echo "error_type";
                                 }
                             } else {
                                 echo "error_size";
                             }
                         } else {
                             echo "error_null";
                         }
                     } else {
                         if ($action == 'addsub') {
                             $pid = Arr::get($_POST, 'pid');
                             $dest = ORM::factory('destinations');
                             $dest->pid = $pid;
                             $dest->kindname = "未命名";
                             $dest->save();
                             if ($dest->saved()) {
                                 $dest->reload();
                                 $dest->updateSibling('add');
开发者ID:lz1988,项目名称:stourwebcms,代码行数:67,代码来源:destination.php


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