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


PHP Upload::getError方法代码示例

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


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

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

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

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

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

示例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)
 {
     /* 上传文件 */
     $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

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

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

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

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

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

示例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'] = $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

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

示例14: file_post

 /**
  * 文件上传
  */
 public function file_post()
 {
     $redirect_url = I('get.redirect_url');
     //用于跨域上传的回调地址
     $callback = I('get.cb');
     //用于跨域上传的回调脚本
     $uid = I('get.uid', null);
     if (!$uid) {
         $this->check_token();
         $uid = $this->{$uid};
     }
     $type = I('get.type', 'normal');
     $config = C('DOWNLOAD_UPLOAD');
     $config['savePath'] = $type . '/';
     $upload = new Upload($config);
     $infos = $upload->upload();
     // var_dump($infos);
     if (!$infos) {
         if ($redirect_url) {
             $redirect_url = str_replace('{data}', urlencode(base64_encode(json_encode(array('success' => false, 'code' => '1400', 'message' => $upload->getError())))), $redirect_url);
             header('Location: ' . $redirect_url);
             redirect($redirect_url);
             return;
         }
         $this->errorMsg('1400', $upload->getError());
     } else {
         $tmp = array();
         foreach ($infos as &$info) {
             $id = $this->saveFileInfo($uid, $info);
             $info['id'] = $id;
             $info['status'] = 1;
             //$file_path = null;
             $file_path = $info['savepath'] . $info['savename'];
             //$filename = empty ( $file_path ) ? $info ['sha1'] . $info['ext'] : $file_path;
             $file_url = 'http://image.alhelp.net/attachments/' . $file_path;
             $info['url'] = $file_url;
             if ($id === false) {
                 $info['status'] = 0;
                 $info['id'] = null;
             }
             $tmp[] = $info;
         }
         if ($redirect_url) {
             $redirect_url = str_replace('{data}', urlencode(base64_encode(json_encode(array('success' => true, 'data' => $tmp)))), $redirect_url);
             header('Location: ' . $redirect_url);
             redirect($redirect_url);
             return;
         }
         $this->success($tmp);
     }
     if ($redirect_url) {
         $redirect_url = str_replace('{data}', urlencode(json_encode(array('success' => false, 'code' => '1417', 'message' => '上传失败'))), $redirect_url);
         $this->redirect($redirect_url);
         return;
     }
     $this->error(1417);
 }
开发者ID:jkzleond,项目名称:alhelp_api,代码行数:60,代码来源:UploadController.class.php

示例15: 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);
     foreach ($files as $key => $file) {
         $ext = strtolower($file['ext']);
         if (in_array($ext, array('jpg', 'jpeg', 'bmp', 'png'))) {
             hook('dealPicture', $file['tmp_name']);
         }
     }
     $info = $Upload->upload($files);
     if ($info) {
         //文件上传成功,记录文件信息
         foreach ($info as $key => &$value) {
             /* 已经存在文件记录 */
             if (isset($value['id']) && is_numeric($value['id'])) {
                 continue;
             }
             /* 记录文件信息 */
             if (strtolower($driver) == 'sae') {
                 $value['path'] = $config['rootPath'] . 'Picture/' . $value['savepath'] . $value['savename'];
                 //在模板里的url路径
             } else {
                 if (strtolower($driver) != 'local') {
                     $value['path'] = $value['url'];
                 } else {
                     $value['path'] = substr($setting['rootPath'], 1) . $value['savepath'] . $value['savename'];
                     //在模板里的url路径
                 }
             }
             $value['type'] = $driver;
             if ($this->create($value) && ($id = $this->add())) {
                 $value['id'] = $id;
             } else {
                 //TODO: 文件上传成功,但是记录文件信息失败,需记录日志
                 unset($info[$key]);
             }
         }
         foreach ($info as &$t_info) {
             if ($t_info['type'] == 'local') {
                 $t_info['path'] = get_pic_src($t_info['path']);
             } else {
                 $t_info['path'] = $t_info['path'];
             }
         }
         /*  dump(getRootUrl());
             dump($info);
             exit;*/
         return $info;
         //文件上传成功
     } else {
         $this->error = $Upload->getError();
         return false;
     }
 }
开发者ID:ccccy,项目名称:wuanlife,代码行数:65,代码来源:PictureModel.class.php


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