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('产品信息更新失败');
         }
     }
 }
Beispiel #2
0
 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('修改成功');
     }
 }
Beispiel #3
0
 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();
 }
 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)) {
 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("上传文件不完整或没有文件被上传!");
     }
 }
Beispiel #6
0
 /**
  * 文件上传
  * @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;
     }
 }
Beispiel #7
0
 /**
  * 文件上传
  * @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;
     }
 }
 /**
  * 文件上传
  * @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;
     }
 }
 /**
  * 文件上传
  * @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;
     }
 }
 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);
 }
 /**
  * 
  */
 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);
 }
Beispiel #12
0
 /**
  * 文件上传
  * @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;
     }
 }
 /**
  * 文件上传
  * @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;
     }
 }
 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());
         }
 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();
     }
 }
 /**
  * 文件上传
  * @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) == 'qiniu') {
                     $value['path'] = substr($setting['rootPath'], 1) . $value['savepath'] . $value['savename'];
                 } elseif (strtolower($driver) != 'local') {
                     $value['path'] = $value['url'];
                 } else {
                     $value['path'] = substr($setting['rootPath'], 1) . $value['savepath'] . $value['savename'];
                     //在模板里的url路径
                 }
             }
             $value['type'] = strtolower($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'] = fixAttachUrl($t_info['path']);
             } else {
                 $t_info['path'] = $t_info['path'];
             }
         }
         /*  dump(getRootUrl());
             dump($info);
             exit;*/
         return $info;
         //文件上传成功
     } else {
         $this->error = $Upload->getError();
         return false;
     }
 }
 /**
  * 文件上传
  */
 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);
 }
Beispiel #18
0
 /**
  * 保存到当前服务器
  * @return array
  */
 public function save()
 {
     $upload = new Upload($this->config);
     $info = $upload->upload($this->files);
     if (!$info) {
         return $upload->getError();
     }
     $this->info = $info;
     return false;
 }
     }
     //print_r($ans);
     $this->list = $ans;
     $this->display();
 }
 public function material_upload()
 {
     $type = I('POST.action_type');
     if ($type == 'OtherStuff' || $type == 'OtherPlace') {
         $name = 'file_' . $type;
         $upload = new Upload();
         // 实例化上传类
         $upload->maxSize = 3145728;
         // 设置附件上传大小
         $upload->allowExts = array('doc', 'docx');
         // 设置附件上传类型
         $upload->savePath = './Material/' . $type . '/';
         // 设置附件上传目录
         if (!($info = $upload->upload())) {
             // 上传错误提示错误信息
             $this->error($upload->getError());
         }
         print_r($info);
         $sql = M(strtolower($type));
         $data = array();
         $data['Username'] = I('session.username', '');
         $data['ReviewState'] = 0;
         $data['CreateTime'] = date("Y年n月j日 G:i:s");
         $data['Path'] = './Upload/' . substr($info[$name]['savepath'], 1) . $info[$name]['savename'];
         $data['Name'] = $info[$name]['name'];
         $data['AssociationName'] = '';
         $result = $sql->data($data)->add();
         if ($result) {
             $this->success(L('操作成功!'));
         } else {
             $this->error($sql->getError());
         }
         return;
     }
     $sql = M(strtolower(I('POST.action_type')));
     $all_data = I('POST.');
     $data = array();
     foreach ($all_data as $key => $value) {
         if (preg_match('/(.*)_' . $type . '$/', $key, $match)) {
             $data[$match[1]] = $value;
         }
     }
     if ($type == 'BuildingClassroom2') {
         $data['AssociationName'] = $data['Faculty'];
     }
     $data['Username'] = I('session.username', '');
     $data['ReviewState'] = 0;
     $data['CreateTime'] = date("Y年n月j日 G:i:s");
     $result = $sql->data($data)->add();
     if ($result) {
 /**
  * 
  * 上传头像
  * @param string $head
  * @param array $file
  */
 public function uploadHead($head, $file)
 {
     $upload = new Upload($this->_head_config);
     $info = $upload->upload($_FILES);
     if (!$info) {
         return $upload->getError();
     }
     $file = $info['head_image'];
     $data['filename'] = $file['savename'];
     $data['head'] = $head;
     return D('head')->add($data) ? true : '图像数据保存失败';
 }
 public function upload()
 {
     $Upload = new Upload();
     $Upload->rootPath = C('UPLOAD_PATH');
     $info = $Upload->upload();
     if ($info) {
         $imgPath = $info['Filedata']['url'];
         echo $imgPath;
     } else {
         $this->ajaxReturn($Upload->getError());
     }
 }
 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();
     }
 }
 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();
     }
 }
 public function upload()
 {
     $upload = new \Think\Upload();
     $upload->maxSize = 3333333;
     $upload->exts = array('jpg', 'gif', 'png', 'jpeg');
     $upload->savePath = "Public/Uploads/";
     $info = $upload->upload();
     if (!$info) {
         $this->error($upload->getError());
     } else {
         $this->success("上传成功");
     }
 }
Beispiel #25
0
 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));
 }
 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();
     }
 }
 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上的地址
     }
 }
 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();
     }
 }
 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();
     }
 }
Beispiel #30
0
 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();
     }
 }