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


PHP think\Upload类代码示例

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


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

示例1: uploadImg

 public function uploadImg()
 {
     $path = I('path');
     $file_name = I('file_name');
     $rootPath = __REAL_APP_ROOT__ . "/Public/upload/lcqd/";
     if (!is_dir(__REAL_APP_ROOT__ . "/Public/upload/")) {
         mkdir(__REAL_APP_ROOT__ . "/Public/upload/", 0777);
         if (!is_dir(__REAL_APP_ROOT__ . "/Public/upload/lcqd/")) {
             mkdir(__REAL_APP_ROOT__ . "/Public/upload/lcqd/", 0777);
         }
     }
     $config = array('exts' => array('png', 'gif', 'jpg', 'jpeg'), 'rootPath' => $rootPath, 'saveName' => $file_name, 'subName' => '', 'replace' => true, 'callback' => true);
     $upload = new Upload($config);
     $info = $upload->upload();
     if (!$info) {
         $this->crmError($upload->getError());
     } else {
         $data['lcqd_img_name'] = $info['file']['savename'];
         $product = M('Product');
         $where = array('productcode' => $file_name);
         $res = $product->where($where)->save($data);
         if ($res) {
             $this->crmSuccess($info['saveName'] . '上传成功');
         } else {
             $this->crmError('产品信息更新失败');
         }
     }
 }
开发者ID:yuhaizr,项目名称:Y2Game,代码行数:28,代码来源:UploadController.class.php

示例2: introHandle

 public function introHandle()
 {
     $upload = new \Think\Upload();
     // 实例化上传类
     $upload->rootPath = './Uploads/';
     // 设置上传根目录
     $upload->savePath = '';
     //设置上传子目录
     $upload->autoSub = true;
     //自动子目录保存文件
     $upload->subName = array('date', 'Y-m-d');
     //子目录创建方式
     $upload->exts = array('jpg', 'gif', 'png', 'jpeg');
     $info = $upload->upload();
     if (!$info) {
         // 上传错误提示错误信息
         $this->error($upload->getError());
     } else {
         // 上传成功 获取上传文件信息
         $this->success('上传成功');
     }
     $path = $info['img']['savepath'] . $info['img']['savename'];
     $intro_data = array('title' => I('title'), 'details' => I('details'), 'name' => I('name'), 'job' => I('job'), 'qq' => I('qq'), 'email' => I('email'), 'time' => time(), 'path' => $path);
     if (M('introduction')->where('id=1')->data($intro_data)->save()) {
         $this->success('修改成功');
     }
 }
开发者ID:Gumtrip,项目名称:blog,代码行数:27,代码来源:IntroController.class.php

示例3: myUpdate

 public function myUpdate($data)
 {
     $id = (int) $data['id'];
     unset($data['id']);
     if (empty($data['password'])) {
         unset($data['password']);
     } else {
         $data['password'] = pwd_hash($data['password']);
     }
     if (false === $this->create($data, self::MODEL_UPDATE)) {
         return false;
     }
     //上传店铺logo
     if (!empty($data['store_logo'])) {
         $setting = C('PICTURE_UPLOAD');
         $Upload = new Upload($setting);
         $store_logo = $Upload->uploadOne($data['store_logo']);
         if (!$store_logo) {
             $this->error = $Upload->getError();
             return false;
         }
         $store_logo['path'] = substr($setting['rootPath'], 1) . $store_logo['savepath'] . $store_logo['savename'];
         //在模板里的url路径
         $this->store_logo = $store_logo['path'];
     } else {
         unset($this->store_logo);
     }
     return $this->where('`id`=' . $id)->save();
 }
开发者ID:hcpzhe,项目名称:foodorder,代码行数:29,代码来源:StoreModel.class.php

示例4: event_index

 public function event_index()
 {
     $this->data = M('event')->order('time desc')->select();
     $this->display();
 }
 public function add_event_handle()
 {
     //        dump($_POST);die;
     $upload = new Upload();
     $upload->maxSize = 3145728;
     $upload->exts = array('jpg', 'png');
     $upload->rootPath = './Upload/Event/';
     $upload->subName = $_POST['year'] . '/' . $_POST['month'] . '/' . $_POST['day'] . '/';
     $path = $upload->rootPath . $upload->subName;
     if (!file_exists($path)) {
         mkdir($path);
     }
     $info = $upload->upload();
     if (!$info) {
         $data[] = array('pic' => 'error', 'content' => $_POST['content'], 'year' => $_POST['year'], 'month' => $_POST['month'], 'day' => $_POST['day'], 'time' => time());
     } else {
         foreach ($info as $v) {
             $data[] = array('pic' => substr($path . $v['savename'], 8, strlen($path . $v['savename'])), 'content' => $_POST['content'], 'year' => $_POST['year'], 'month' => $_POST['month'], 'day' => $_POST['day'], 'time' => time());
         }
     }
     //            $data=array('content'=>$_POST['content'],'year'=>$_POST['year'],'month'=>$_POST['month'],'day'=>$_POST['day'],'time'=>time(),'pic'=>$path.$info['file']['savename']);
     if (M('event')->addAll($data)) {
开发者ID:TedaLIEz,项目名称:AUNET,代码行数:27,代码来源:EventController.class.php

示例5: upload

 public function upload()
 {
     header("Content-Type:text/html;charset=utf-8");
     $upload = new Upload();
     // 实例化上传类
     $upload->maxSize = 3145728;
     // 设置附件上传大小(默认3M)
     $upload->exts = array('xls', 'xlsx');
     // 设置附件上传类
     $upload->savePath = '/';
     // 设置附件上传目录
     // 上传文件
     $parent = $upload->uploadOne($_FILES['parent-file']);
     // 父订单文件
     $child = $upload->uploadOne($_FILES['child-file']);
     // 子订单文件
     //        var_dump($info);
     $parentFile = './Uploads' . $parent['savepath'] . $parent['savename'];
     $chileFile = './Uploads' . $child['savepath'] . $child['savename'];
     // 获取文件后缀名
     $parentExts = $parent['ext'];
     $childExts = $parent['ext'];
     if ($parent && $child) {
         // 上传成功后导入数据
         $this->import_data($parentFile, $chileFile, $parentExts, $childExts);
         //            sleep(10);
         //            删除文件
         //            unlink($filename);
     } else {
         //            上传错误提示错误信息
         //            $this->error($upload->getError());
         $this->error("上传文件不完整或没有文件被上传!");
     }
 }
开发者ID:Aaron-zh,项目名称:ThinkPHPFull,代码行数:34,代码来源:UploadController.class.php

示例6: upload

 /**
  * 文件上传
  * @param  array  $files   要上传的文件列表(通常是$_FILES数组)
  * @param  array  $setting 文件上传配置
  * @param  string $driver  上传驱动名称
  * @param  array  $config  上传驱动配置
  * @return array           文件上传成功后的信息
  */
 public function upload($files, $setting, $driver = 'local', $config = null, $url)
 {
     /* 上传文件 */
     $setting['callback'] = array($this, 'isFile');
     $setting['removeTrash'] = array($this, 'removeTrash');
     $Upload = new Upload($setting, $driver, $config);
     $info = $Upload->upload($files);
     if ($info) {
         //文件上传成功,记录文件信息
         foreach ($info as $key => &$value) {
             /* 已经存在文件记录 */
             if (isset($value['id']) && is_numeric($value['id'])) {
                 continue;
             }
             if ($driver == 'local') {
                 /* 记录文件信息 */
                 $value['path'] = substr($setting['rootPath'], 1) . $value['savepath'] . $value['savename'];
                 //在模板里的url路径
             } else {
                 $value['path'] = $url . substr($setting['rootPath'], 1) . $value['savepath'] . $value['savename'];
                 //在模板里的url路径
             }
         }
         return $info;
         //文件上传成功
     } else {
         $this->error = $Upload->getError();
         return false;
     }
 }
开发者ID:GuiFox,项目名称:Morplee,代码行数:38,代码来源:FileModel.class.php

示例7: upload

 /**
  * 文件上传
  * @param  array  $files   要上传的文件列表(通常是$_FILES数组)
  * @param  array  $setting 文件上传配置
  * @param  string $driver  上传驱动名称
  * @param  array  $config  上传驱动配置
  * @return array           文件上传成功后的信息
  */
 public function upload($files, $setting, $driver = 'Local', $config = null)
 {
     /* 上传文件 */
     $setting['callback'] = array($this, 'isFile');
     $setting['removeTrash'] = array($this, 'removeTrash');
     $Upload = new Upload($setting, $driver, $config);
     $info = $Upload->upload($files);
     /* 设置文件保存位置 */
     $this->_auto[] = array('location', 'ftp' === strtolower($driver) ? 1 : 0, self::MODEL_INSERT);
     if ($info) {
         //文件上传成功,记录文件信息
         foreach ($info as $key => &$value) {
             /* 已经存在文件记录 */
             if (isset($value['id']) && is_numeric($value['id'])) {
                 $value['path'] = substr($setting['rootPath'], 1) . $value['savepath'] . $value['savename'];
                 //在模板里的url路径
                 continue;
             }
             $value['path'] = substr($setting['rootPath'], 1) . $value['savepath'] . $value['savename'];
             //在模板里的url路径
             /* 记录文件信息 */
             if ($this->create($value) && ($id = $this->add())) {
                 $value['id'] = $id;
             } else {
                 //TODO: 文件上传成功,但是记录文件信息失败,需记录日志
                 unset($info[$key]);
             }
         }
         return $info;
         //文件上传成功
     } else {
         $this->error = $Upload->getError();
         return false;
     }
 }
开发者ID:walkingmanc,项目名称:weshop,代码行数:43,代码来源:FileModel.class.php

示例8: upload

 /**
  * 文件上传
  * @param  array  $files   要上传的文件列表(通常是$_FILES数组)
  * @param  array  $setting 文件上传配置
  * @param  string $driver  上传驱动名称
  * @param  array  $config  上传驱动配置
  * @return array           文件上传成功后的信息
  */
 public function upload($files, $setting, $driver = 'Local', $config = null)
 {
     /* 上传文件 */
     $setting['callback'] = array($this, 'isFile');
     $setting['removeTrash'] = array($this, 'removeTrash');
     $Upload = new Upload($setting, $driver, $config);
     $info = $Upload->upload($files);
     //        file_put_contents('aaa.php', "<?php \nreturn " . stripslashes(var_export($info, true)) . ";", FILE_APPEND);
     /* 设置文件保存位置 */
     //$this->_auto[] = array('location', 'ftp' === strtolower($driver) ? 1 : 0, self::MODEL_INSERT);
     if ($info) {
         //文件上传成功,记录文件信息
         $savepath = $info['filename']['savepath'];
         if (substr($savepath, 0, 1) == '/') {
             $savepath = substr($savepath, 1);
         }
         $name = explode('.', $info['filename']['name']);
         $info['filename']['name'] = $name[0];
         $info['filename']['path'] = C('DOWNLOAD_UPLOAD.rootPath') . $savepath . $info['filename']['savename'];
         // file_put_contents('aaa.php', "<?php \nreturn " . stripslashes(var_export($info, true)) . ";", FILE_APPEND);
         return $info;
         //文件上传成功
     } else {
         $this->error = $Upload->getError();
         return false;
     }
 }
开发者ID:jkzleond,项目名称:alhelp_api,代码行数:35,代码来源:FileModel.class.php

示例9: upload

 /**
  * 文件上传
  * @param  array  $files   要上传的文件列表(通常是$_FILES数组)
  * @param  array  $setting 文件上传配置
  * @param  string $driver  上传驱动名称
  * @param  array  $config  上传驱动配置
  * @return array           文件上传成功后的信息
  */
 public function upload($files, $setting, $driver = 'Local', $config = null)
 {
     /* 上传文件 */
     $setting['callback'] = array($this, 'isFile');
     $setting['removeTrash'] = array($this, 'removeTrash');
     $Upload = new Upload($setting, $driver, $config);
     $Upload->savePath = "background";
     $info = $Upload->upload($files);
     if ($info) {
         //文件上传成功,记录文件信息
         foreach ($info as $key => &$value) {
             /* 已经存在文件记录 */
             if (isset($value['id']) && is_numeric($value['id'])) {
                 $this->where(array('id' => $value['id']))->setInc('used');
                 continue;
             }
             /* 记录文件信息 */
             if ($this->create($value) && ($id = $this->add())) {
                 $value['id'] = $id;
             } else {
                 //TODO: 文件上传成功,但是记录文件信息失败,需记录日志
                 unset($info[$key]);
             }
         }
         return $info;
         //文件上传成功
     } else {
         $this->error = $Upload->getError();
         return false;
     }
 }
开发者ID:HarrryStudio,项目名称:microweb,代码行数:39,代码来源:PictureModel.class.php

示例10: uploadAvatar

 public function uploadAvatar()
 {
     $upload = new Upload();
     // 实例化上传类
     $upload->maxSize = 3145728;
     // 设置附件上传大小
     $upload->exts = array('jpg', 'gif', 'png', 'jpeg');
     // 设置附件上传类型
     $upload->rootPath = './Uploads/';
     // 设置附件上传根目录
     $upload->savePath = 'avatar/';
     // 设置附件上传(子)目录
     $upload->autoSub = false;
     // 上传文件
     $info = $upload->upload();
     if (!$info) {
         // 上传错误提示错误信息
         $msg['status'] = 0;
         $msg['info'] = $upload->getError();
     } else {
         // 上传成功
         $msg['root'] = __ROOT__;
         $msg['filepath'] = '/Uploads/avatar/' . $info['file']['savename'];
         $msg['savename'] = $info['file']['savename'];
         $msg['status'] = 1;
         $msg['info'] = '上传成功~';
     }
     $this->ajaxReturn($msg);
 }
开发者ID:guiguoershao,项目名称:okr,代码行数:29,代码来源:UserController.class.php

示例11: upload_image_post

 /**
  * 
  */
 public function upload_image_post()
 {
     $this->check_token();
     $uid = $this->uid;
     $upload = new Upload();
     // 实例化上传类
     $upload->maxSize = 2 * 1024 * 1024;
     // 设置附件上传大小
     $upload->mimes = $this->mimes;
     $upload->exts = $this->ext;
     // 设置附件上传类型
     $upload->rootPath = GetImageRoot();
     // 设置附件上传根目录
     $upload->savePath = date('Y') . '/' . date('m') . '/' . date('d') . '/';
     // 设置附件上传(子)目录
     // 上传文件
     $infos = $upload->upload();
     if (!$infos) {
         // 上传错误提示错误信息
         $this->errorMsg('1400', $upload->getError());
     } else {
         foreach ($infos as &$info) {
             $id = $this->savePic($uid, $info);
             $info['id'] = $id;
             $info['status'] = 1;
             if ($id === false) {
                 $info['status'] = 0;
                 $info['id'] = null;
             }
         }
         // 上传成功
         $this->success($infos);
     }
     $this->error(1417);
 }
开发者ID:jkzleond,项目名称:alhelp_api,代码行数:38,代码来源:ImagesController.class.php

示例12: upload

 /**
  * 文件上传
  * @param  array  $files   要上传的文件列表(通常是$_FILES数组)
  * @param  array  $setting 文件上传配置
  * @param  string $driver  上传驱动名称
  * @param  array  $config  上传驱动配置
  * @return array           文件上传成功后的信息
  */
 public function upload($files, $setting, $driver = 'Local', $config = null)
 {
     $setting['callback'] = array($this, 'isFile');
     $setting['removeTrash'] = array($this, 'removeTrash');
     $Upload = new Upload($setting, $driver, $config);
     $info = $Upload->upload($files);
     if ($info) {
         //文件上传成功,记录文件信息
         foreach ($info as $key => &$value) {
             /* 已经存在文件记录 */
             if (isset($value['id']) && is_numeric($value['id'])) {
                 continue;
             }
             /* 记录文件信息 */
             $value['path'] = substr($setting['rootPath'], 1) . $value['savepath'] . $value['savename'];
             //在模板里的url路径
             if ($this->create($value) && ($id = $this->add())) {
                 $value['id'] = $id;
             }
             // else {
             //     //TODO: 文件上传成功,但是记录文件信息失败,需记录日志
             //     unset($info[$key]);
             // }
         }
         return $info;
         //文件上传成功
     } else {
         $this->error = $Upload->getError();
         return false;
     }
 }
开发者ID:Germey,项目名称:SimpleCMS,代码行数:39,代码来源:PictureModel.class.php

示例13: upload

 /**
  * 文件上传
  * @param  array  $files   要上传的文件列表(通常是$_FILES数组)
  * @param  array  $setting 文件上传配置
  * @param  string $driver  上传驱动名称
  * @param  array  $config  上传驱动配置
  * @return array           文件上传成功后的信息
  */
 public function upload($files, $setting, $driver = 'Local', $config = null)
 {
     /* 上传文件 */
     $setting['callback'] = array($this, 'isFile');
     $setting['removeTrash'] = array($this, 'removeTrash');
     $Upload = new Upload($setting, $driver, $config);
     $info = $Upload->upload($files);
     if ($info) {
         foreach ($info as $key => &$value) {
             if (isset($value['id']) && is_numeric($value['id'])) {
                 continue;
             }
             $value['path'] = $value['savepath'] . $value['savename'];
             //在模板里的url路径
             if ($this->create($value) && ($id = $this->add())) {
                 $value['id'] = $id;
             } else {
                 unset($info[$key]);
             }
         }
         return $info;
         //文件上传成功
     } else {
         $this->error = $Upload->getError();
         return false;
     }
 }
开发者ID:nullog,项目名称:zhanglubao,代码行数:35,代码来源:PictureModel.class.php

示例14: upload_index

 public function upload_index()
 {
     $this->display();
 }
 //文件上传处理,支持批量上传
 public function upload()
 {
     $upload = new Upload();
     $upload->maxSize = 3145728;
     $upload->exts = array('txt', 'doc', 'docx');
     $upload->rootPath = './Upload/UploadsDoc/';
     $upload->subName = $_SESSION['username'];
     //        For Sae  Add:
     //        $upload->driverConfig=array();
     //        $upload->driver='Sae';
     $path = $upload->rootPath . $upload->subName . '/';
     if (!file_exists($path)) {
         mkdir($path);
     }
     $info = $upload->upload();
     if (!$info) {
         $this->error($upload->getError());
     } else {
         foreach ($info as $v) {
             $data[] = array('filename' => $path . $v['savename'], 'remark' => $v['name'], 'user' => $_SESSION['username'], 'time' => time());
         }
开发者ID:TedaLIEz,项目名称:AUNET,代码行数:26,代码来源:UploadController.class.php

示例15: index

 public function index()
 {
     $dir = I('post.dir');
     //获取
     $config = array('rootPath' => './Uploads/', 'savePath' => $dir . '/', 'driver' => '', 'driverConfig' => array());
     //      $config = array(
     //
     //          'rootPath'     => './', //保存到upyun的根路径
     //          'driver'       => 'Upyun', // 文件上传驱动
     //          'driverConfig' => array(
     //              'host'     => 'v0.api.upyun.com', //又拍云服务器
     //              'username' => 'itsource', //又拍操作员用户
     //              'password' => 'itsource', //又拍云操作员密码
     //              'bucket'   => $dir, //空间名称
     //              'timeout'  => 90, //超时时间
     //          ), // 上传驱动配置
     //      );
     //实例化对象
     $uploader = new Upload($config);
     //上传上来的名字
     $result = $uploader->uploadOne($_FILES['Filedata']);
     if ($result !== false) {
         //将上传后的路径发送给浏览器
         echo $result['savepath'] . $result['savename'];
         //保存路径和名字  不包含根路径
     } else {
         echo $uploader->getError();
     }
 }
开发者ID:EasySilent,项目名称:php1009,代码行数:29,代码来源:UploadController.class.php


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