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


PHP Upload::uploadOne方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: uploadOne

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

示例5: index

 public function index()
 {
     $dir = I('post.dir');
     $config = array('rootPath' => './', 'driver' => 'Upyun', 'driverConfig' => array('host' => 'v0.api.upyun.com', 'username' => 'doushopdou', 'password' => 'doushopdou', '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:githublming,项目名称:1009php,代码行数:12,代码来源:UploadController.class.php

示例6: upload2

 public function upload2()
 {
     $file = $_FILES['file'];
     $upload = new \Think\Upload();
     // 实例化上传类
     $upload->maxSize = 2 * 1024 * 1024;
     $upload->rootPath = './Uploads/';
     // 设置附件上传根目录
     $upload->savePath = 'Picture/';
     // 设置附件上传(子)目录
     $info = $upload->uploadOne($file);
     exit(json_encode($info));
 }
开发者ID:tearys,项目名称:lucky,代码行数:13,代码来源:IndexController.class.php

示例7: index

 public function index()
 {
     $dir = I('post.dir');
     //echo $dir;
     $config = array('rootPath' => './Uploads/', 'savePath' => $dir . "/");
     $upload = new Upload($config);
     $result = $upload->uploadOne($_FILES['Filedata']);
     if ($result) {
         echo $result['savepath'] . $result['savename'];
     } else {
         echo $upload->getError();
     }
 }
开发者ID:zhouliwen,项目名称:php0110,代码行数:13,代码来源:UploadController.class.php

示例8: upload

 public function upload()
 {
     $dir = I('post.dir');
     //如果要将配置放到配置文件中,需要将$dir提出来
     $config = array('rootPath' => './', 'driver' => 'Upyun', 'driverConfig' => array('host' => 'v0.api.upyun.com', 'username' => 'brazor', 'password' => 'brazorbrazor', 'bucket' => $dir, 'timeout' => 90));
     $upload = new Upload();
     $result = $upload->uploadOne($_FILES['Filedata']);
     if ($result !== false) {
         echo $result['savepath'] . $result['savename'];
     } else {
         echo $upload->getError();
     }
 }
开发者ID:ahblin,项目名称:michael0112,代码行数:13,代码来源:UploadController.class.php

示例9: index

 public function index()
 {
     $dir = I('post.dir');
     //获取浏览器指定的服务(空间)
     $config = array('rootPath' => './Uploads/', 'savePath' => $dir . '/', 'driverConfig' => array());
     $uploader = new Upload($config);
     $result = $uploader->uploadOne($_FILES['Filedata']);
     if ($result !== false) {
         //将上传后的路径发送给浏览器
         echo $result['savepath'] . '/' . $result['savename'];
         //保存到upyun上的地址
     }
 }
开发者ID:aa123123,项目名称:php1009,代码行数:13,代码来源:UploadController.class.php

示例10: index

 public function index()
 {
     $dir = I('post.dir');
     $config = C('UPLOAD_CONFIG');
     $config['driverConfig']['bucket'] = $dir;
     $uploader = new Upload($config);
     $rst = $uploader->uploadOne($_FILES['Filedata']);
     if ($rst !== false) {
         echo $rst['savepath'] . $rst['savename'];
     } else {
         echo $uploader->getError();
     }
 }
开发者ID:myservergit,项目名称:linux_shop,代码行数:13,代码来源:UploadController.class.php

示例11: index

 public function index()
 {
     //获取浏览器指定的服务(空间
     $dir = I("post.dir");
     $config = array('rootPath' => './', 'driver' => 'Upyun', 'driverConfig' => array('host' => 'v0.api.upyun.com', 'username' => 'xluo', 'password' => 'lshaulu0.', 'bucket' => $dir, 'timeout' => 90));
     $upload = new Upload($config);
     $rst = $upload->uploadOne($_FILES['Filedata']);
     if ($rst !== false) {
         echo $rst['savepath'] . $rst['savename'];
     } else {
         $upload->getError();
     }
 }
开发者ID:zaibuxingwojiiugodie,项目名称:shop,代码行数:13,代码来源:UploadController.class.php

示例12: index

 public function index()
 {
     $dir = I('post.dir');
     //上传配置信息
     $config = array('maxSize' => 0, 'exts' => array(), 'autoSub' => true, 'subName' => array('date', 'Y-m-d'), 'rootPath' => './Uploads/', 'savePath' => $dir . '/', 'saveExt' => '', 'replace' => false, 'callback' => false, 'driver' => '', 'driverConfig' => array());
     $upload = new Upload($config);
     $result = $upload->uploadOne($_FILES['Filedata']);
     if ($result !== false) {
         //将上传后的路径发送给浏览器
         echo $result['savepath'] . $result['savename'];
         //保存到的地址
     } else {
         echo $upload->getError();
     }
 }
开发者ID:liunanx,项目名称:php1009,代码行数:15,代码来源:UploadsController.class.php

示例13: index

 public function index()
 {
     //获取到文件存放的文件夹
     $dir = I('post.dir');
     $config = array('rootPath' => './', 'savePath' => $dir . '/', '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'];
         //保存到upyun上的地址
     } else {
         echo $uploader->getError();
     }
 }
开发者ID:okjiex,项目名称:shop,代码行数:15,代码来源:UploadController.class.php

示例14: index

 public function index()
 {
     //保存路径,即根目录下的文件夹
     $dir = I('post.dir');
     //配置
     $config = array('rootPath' => './', 'driver' => 'Upyun', 'driverConfig' => array('host' => 'v0.api.upyun.com', 'username' => 'nalanshiwu', 'password' => 'Zwj175370', 'bucket' => $dir, 'timeout' => 90));
     $model = new Upload($config);
     $result = $model->uploadOne($_FILES['Filedata']);
     if ($result !== false) {
         //保存地址
         echo $result['savepath'] . $result['savename'];
     } else {
         $this->error('上传失败' . $model->getError());
     }
 }
开发者ID:zhaowj666,项目名称:linux_shop,代码行数:15,代码来源:UploadController.class.php

示例15: index

 public function index()
 {
     $dir = I('post.dir');
     //从配置中获得上传配置
     $config = C('UPLOAD_COF');
     //设置上传的upyun的服务
     $config['driverConfig']['bucket'] = $dir;
     $upload = new Upload($config);
     $rst = $upload->uploadOne($_FILES['Filedata']);
     if ($rst !== false) {
         echo $rst['savepath'] . $rst['savename'];
     } else {
         echo '上传失败:' . $upload->getError();
     }
 }
开发者ID:dower-d,项目名称:shop,代码行数:15,代码来源:UploadController.class.php


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