當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。