松山顶峰, 洛杉矶国家森林公园, 加利福尼亚州, 美国 (© Matthew Kuhns/TANDEM Stills + Motion)

Welcom to 评论 - lizhenqiu blog!

    #172

    作者:广西南宁市
    tp6 汉字转拼音
    下载拓展文件,放在extend目录下

    控制器中使用
    引入拓展文件:use topinyin\ChinesePinyin;
    public function indexOp() { $Pinyin = new ChinesePinyin(); //带声调的汉语拼音 echo '我们的歌'; dump($Pinyin->TransformWithTone("我们的歌")); //无声调的汉语拼音 echo '我们的歌'; dump($Pinyin->TransformWithoutTone("我们的歌")); //转成汉语拼音首字母,只包括汉字,不包含拼音 echo '首字母只包括汉字BuHanPinYin'; dump($Pinyin->TransformUcwordsOnlyChar("首字母只包括汉字BuHanPinYin")); //转成汉语拼音首字母,包含非汉字内容 echo '首字母和其他字符如B区32号'; dump($Pinyin->TransformUcwords("首字母和其他字符如B区32号")); }
    Run code
    Cut to clipboard

      文章:php获得汉字拼音首字母  发表时间:2022-07-29, 09:24:00  
      展开↯

      #173

      作者:广西南宁市
      php 获取中文字符拼音首字母
      //php获取中文字符拼音首字母 function getFirstCharter($str){ if(empty($str)){return '';} $fchar=ord($str{0}); if($fchar>=ord('A')&&$fchar<=ord('z')) return strtoupper($str{0}); $s1=iconv('UTF-8','gb2312',$str); $s2=iconv('gb2312','UTF-8',$s1); $s=$s2==$str?$s1:$str; $asc=ord($s{0})*256+ord($s{1})-65536; if($asc>=-20319&&$asc<=-20284) return 'A'; if($asc>=-20283&&$asc<=-19776) return 'B'; if($asc>=-19775&&$asc<=-19219) return 'C'; if($asc>=-19218&&$asc<=-18711) return 'D'; if($asc>=-18710&&$asc<=-18527) return 'E'; if($asc>=-18526&&$asc<=-18240) return 'F'; if($asc>=-18239&&$asc<=-17923) return 'G'; if($asc>=-17922&&$asc<=-17418) return 'H'; if($asc>=-17417&&$asc<=-16475) return 'J'; if($asc>=-16474&&$asc<=-16213) return 'K'; if($asc>=-16212&&$asc<=-15641) return 'L'; if($asc>=-15640&&$asc<=-15166) return 'M'; if($asc>=-15165&&$asc<=-14923) return 'N'; if($asc>=-14922&&$asc<=-14915) return 'O'; if($asc>=-14914&&$asc<=-14631) return 'P'; if($asc>=-14630&&$asc<=-14150) return 'Q'; if($asc>=-14149&&$asc<=-14091) return 'R'; if($asc>=-14090&&$asc<=-13319) return 'S'; if($asc>=-13318&&$asc<=-12839) return 'T'; if($asc>=-12838&&$asc<=-12557) return 'W'; if($asc>=-12556&&$asc<=-11848) return 'X'; if($asc>=-11847&&$asc<=-11056) return 'Y'; if($asc>=-11055&&$asc<=-10247) return 'Z'; return null; } echo getFirstCharter('张');
      Run code
      Cut to clipboard
        文章:php获得汉字拼音首字母  发表时间:2022-07-29, 09:19:15  
        展开↯

        #174

        作者:广西南宁市
        // 监听按键 var code = '' var lastTime, nextTime // 上次时间、最新时间 var lastCode, nextCode // 上次按键、最新按键 document.onkeypress = (e) => { // 获取按键 if (window.event) { // IE nextCode = e.keyCode } else if (e.which) { // Netscape/Firefox/Opera nextCode = e.which } // 如果触发了回车事件(扫码结束时间) if (nextCode === 13) { if (code.length < 3) return // 手动输入的时间不会让code的长度大于2,所以这里只会对扫码枪有 this.codeFind(code) // 获取到扫码枪输入的内容,做别的操作 code = '' lastCode = '' lastTime = '' return } nextTime = new Date().getTime() // 记录最新时间 if (!lastTime && !lastCode) { // 如果上次时间和上次按键为空 code += e.key // 执行叠加操作 } // 如果有上次时间及上次按键 if (lastCode && lastTime && nextTime - lastTime > 30) { // 当扫码前有keypress事件时,防止首字缺失 code = e.key } else if (lastCode && lastTime) { code += e.key } lastCode = nextCode lastTime = nextTime }
        Run code
        Cut to clipboard
          文章:js监听页面扫码枪  发表时间:2022-07-26, 17:27:15  
          展开↯

          #175

          作者:广西南宁市
          vue使用扫码枪,全局监听

          全局监听扫码枪的扫码数据
          在 src 下新建文件 scanCode.js,并在 main.js 引入即可

          scanCode.js
          import store from './store' function scanCode() { let str = '' document.onkeydown = function() { if (event.target.tagName !== 'BODY') { str = '' } else { if (event.keyCode !== 13) { if (event.keyCode >= 32 && event.keyCode <= 126) { let k = event.key str += k } } else { if (str) { store.commit('scanCode/SET_SCANSTRING', str) } str = '' } } } } export default scanCode()
          Run code
          Cut to clipboard


            main.js
            import Vue from 'vue' import App from './App' import store from './store' import router from './router' import './scanCode' // 扫码 Vue.config.productionTip = false new Vue({ el: '#app', router, store, render: h => h(App) })
            Run code
            Cut to clipboard


              增加扫码的vuex
              在modules中新建文件scanCode.js,并在getters.js中增加scanString: state => state.scanCode.scanString
              export default { namespaced: true, state: { // 扫码的值 scanString: '' }, mutations: { SET_SCANSTRING: (state, scanString) => { state.scanString = scanString } } }
              Run code
              Cut to clipboard


                监听vuex中scanString的变化
                export default { computed: { scanString() { return this.$store.getters.scanString } }, watch: { scanString(s) { if (s) { setTimeout(() => { // 触发事件 你要做的事 alert(s) // 执行结束后重复为空 this.$store.commit('scanCode/SET_SCANSTRING', '') }, 100) } } } }
                Run code
                Cut to clipboard
                  文章:js监听页面扫码枪  发表时间:2022-07-26, 17:26:46  
                  展开↯

                  #176

                  作者:广西南宁市
                  <script> export default { data() { return { } }, mounted() { // 监听按键 var code = '' var lastTime, nextTime // 上次时间、最新时间 var lastCode, nextCode // 上次按键、最新按键 document.onkeypress = (e) => { // 获取按键 if (window.event) { // IE nextCode = e.keyCode } else if (e.which) { // Netscape/Firefox/Opera nextCode = e.which } // 如果触发了回车事件(扫码结束时间) if (nextCode === 13) { if (code.length < 3) return // 手动输入的时间不会让code的长度大于2,所以这里只会对扫码枪有 this.codeFind(code) // 获取到扫码枪输入的内容,做别的操作 code = '' lastCode = '' lastTime = '' return } nextTime = new Date().getTime() // 记录最新时间 if (!lastTime && !lastCode) { // 如果上次时间和上次按键为空 code += e.key // 执行叠加操作 } // 如果有上次时间及上次按键 if (lastCode && lastTime && nextTime - lastTime > 30) { // 当扫码前有keypress事件时,防止首字缺失 code = e.key } else if (lastCode && lastTime) { code += e.key } lastCode = nextCode lastTime = nextTime } }, methods: { // 业务逻辑根据项目更改 codeFind(code) { if ([123456, 789101].indexOf(code) >= 0) { alert('code已经存在') } } } } </script>
                  Run code
                  Cut to clipboard
                    文章:js监听页面扫码枪  发表时间:2022-07-26, 17:24:58  
                    展开↯

                    #177

                    作者:广西南宁市
                    //监听扫码枪 function ListenScanCodeGun() { var barCode = ''; var lastTime = 0; function ClearBarCode() { barCode = ''; lastTime = 0; } window.addEventListener('keypress', function (e) { console.log("监听开始"); e = e || window.event; var currCode = e.keyCode || e.which || e.charCode; var currTime = new Date().getTime(); if (lastTime > 0) { if (currTime - lastTime <= 100) { barCode += String.fromCharCode(currCode); } else if (currTime - lastTime > 500) { // 输入间隔500毫秒清空 ClearBarCode(); } } else // 第一次按键 { barCode = String.fromCharCode(currCode); } lastTime = currTime; if (currCode == 13) // 回车 { if (barCode && barCode.length >= 8) { // 这里得到码,做下一步业务处理 console.log("最终编号:" + barCode); } // 回车输入后清空 ClearBarCode(); } }); }
                    Run code
                    Cut to clipboard
                      文章:js监听页面扫码枪  发表时间:2022-07-26, 17:24:28  
                      展开↯

                      #178

                      作者:广西南宁市
                      openCodeListDialog(row) { console.log(row) this.$refs.codeList.open(row) }, /* 监听输入 判断通过isScan判断 */ inputCode(v) { console.log(v) if (this.isScan) return; this.code = v }, //处理扫码枪获取的数据 dealScan(code) { this.isScan = false this.sourceCode = code.substring(code.length - 12);//取出后12位 }, scanCode() { console.log(1) let lastTime = null; let nextTime = null; let code = ''; let timer = '' //监听数据录入 通过判断输入数据的速度来判读是手动输入还是扫码枪录入, //这里有一个问题 当用户同时按下两个按键或者故意以高速录入数据时也会被判定为扫码枪输入 document.onkeydown = e => { console.log(e) let keycode = e.keyCode || e.which || e.charCode; nextTime = new Date(); if (keycode === 13) { if (lastTime && (nextTime - lastTime < 30)) { // 扫码枪 this.dealScan(code) } else { // 键盘 console.log('键盘输入') } code = ''; lastTime = null; e.preventDefault(); } else { if (!lastTime) { code = String.fromCharCode(keycode); } else { if (nextTime - lastTime < 30) { code += String.fromCharCode(keycode); item.isScan = true } else { code = ''; item.isScan = false } } lastTime = nextTime; } //添加定时器 防止用户输入过快导致的误判 timer = setTimeout(_ => { clearTimeout(timer) this.isScan = false }, 100) }; },
                      Run code
                      Cut to clipboard
                        文章:js监听页面扫码枪  发表时间:2022-07-26, 17:24:02  
                        展开↯

                        #179

                        作者:广西南宁市
                        代码实现
                        <?php declare (strict_types = 1); namespace app\union\controller; use app\Request; use app\union\model\Groups; use think\facade\Cookie; use think\facade\Db; use think\facade\View; use PHPExcel_IOFactory; //通过composer加载的第三方类,直接在头部引入一下就可以 class Group extends Base { public function import_save(Request $request){ if(!$request->param('excel')){ return returnJson('500','请上传excel文件'); } $path = public_path().$request->param('excel'); //实例化PHPExcel类 $PHPExcel = new \PHPExcel(); //默认用excel2007读取excel,若格式不对,则用之前的版本进行读取 $PHPReader = new \PHPExcel_Reader_Excel2007(); if (!$PHPReader->canRead($path)) { $PHPReader = new \PHPExcel_Reader_Excel5(); if (!$PHPReader->canRead($path)) { return returnJson('500','请上传excel文件'); } } //读取Excel文件 $PHPExcel = $PHPReader->load($path); //读取excel文件中的第一个工作表 $sheet = $PHPExcel->getSheet(0); //取得最大的列号 $allColumn = $sheet->getHighestColumn(); //取得最大的行号 $allRow = $sheet->getHighestRow(); //从第二行开始插入,第一行是列名 for ($currentRow = 2; $currentRow <= $allRow; $currentRow++) { //获取B列的值 $data = [ 'number'=>$PHPExcel->getActiveSheet()->getCell("A" . $currentRow)->getValue(), 'nickName'=>$PHPExcel->getActiveSheet()->getCell("B" . $currentRow)->getValue(), 'name'=>$PHPExcel->getActiveSheet()->getCell("C" . $currentRow)->getValue(), 'tel'=>$PHPExcel->getActiveSheet()->getCell("D" . $currentRow)->getValue(), 'money'=>$PHPExcel->getActiveSheet()->getCell("E" . $currentRow)->getValue(), 'time'=>self::get_date_by_excel($PHPExcel->getActiveSheet()->getCell("F" . $currentRow)->getValue()), 'is_pay'=>$PHPExcel->getActiveSheet()->getCell("G" . $currentRow)->getValue(), 'shop_name'=>$PHPExcel->getActiveSheet()->getCell("H" . $currentRow)->getValue(), 'remarks'=>$PHPExcel->getActiveSheet()->getCell("I" . $currentRow)->getValue(), 'status'=>0, 'created_at'=>date('Y-m-d') ]; if($data['number'] == ''){ $result = 1; continue; }else{ $find = Groups::where(array('number'=>$data['number']))->find(); if($find){ $result = 1; continue; }else{ $result=Db::name('group')->insert($data); } } } if($result){ return returnJson('200','导入成功'); }else{ return returnJson('500','导入失败'); } } public static function get_date_by_excel($date){ if (!$date || $date == '0000-00-00') return null; $unix_time = \PHPExcel_Shared_Date::ExcelToPHP($date); return gmdate('Y-m-d H:i',$unix_time); } } ?>
                        Run code
                        Cut to clipboard
                          文章:tp6安装、封装phpspreadsheet,表格excel导入导出  发表时间:2022-07-26, 09:34:55  
                          展开↯

                          #180

                          作者:广西南宁市
                          文章:@意见反馈/技术支持/伊网/安企网  发表时间:2022-07-13, 17:59:49  
                          展开↯

                          #181

                          作者:广西南宁市
                          电脑的显示器和主机连接的那条线叫什么

                          有VGA,也有DVI,还有HDMI
                          VGA蓝色的接口。
                          DVI是白色的接口。
                          HDMI有点像USB接口,
                          #,广西南宁市,2018-11-19,17:26:37,
                          #,广西南宁市,2018-11-19,17:27:14,
                          #,广西南宁市,2021-09-19,09:15:20, http://www.pixiv.net/member_illust.php?mode=medium&illust_id=92459511
                          #,广西南宁市,2021-09-19,09:27:23,@3, https://www.messynessychic.com/2014/03/05/the-first-monokini-trying-to-make-the-topless-swimsuit-happen-in-1964/
                          #,广西南宁市,2021-09-28,15:45:58, 童年游戏
                          https://www.yikm.net/
                          https://flash.zczc.cz/
                          #,广西南宁市,2021-09-28,17:39:46,
                          #,广西-南宁-中国电信,2021-11-22,00:41:33, proumb
                          cum4k.com
                          #,广西-南宁-中国电信,2021-11-22,00:43:09, https://meanporn.com/
                          #,广西-南宁-中国电信,2021-11-22,00:45:30, https://www.bangingreviews.com/category/videos/
                          #,广西-南宁-中国电信,2021-11-22,00:58:12, http://www.hlshenzhou.com/
                          #,广西-南宁-中国电信,2021-11-22,01:06:16, https://xf.002xf.com/play/1125/3/1.html
                          https://en.kin8tengoku.com/moviepages/3481/index.html
                          #,广西南宁市,2021-11-22,16:36:37, vpn梯子 SuperfastVPN
                          #,广西南宁市,2021-11-24,02:07:07, https://mbltt.com/
                          #,广西-南宁-中国电信,2021-11-24,02:17:28, https://www.veryfreeporn.com/sites/
                          #,广西-南宁-中国电信,2021-11-25,01:01:10, http://bigbustyboobs.net/index.php?page=3
                          #,广西南宁市,2021-11-25,20:00:01, chinesebae.tumblr.com
                          #,广西南宁市,2021-11-25,21:05:43, [PrivateCasting-X / DirtyFlix] - Vegas Teeny Fake Casting Fuck - Danni Rivers
                          #,广西南宁市,2021-11-25,21:06:21,@17, http://www.privatecasting.net/
                          https://www.privatecasting-x.com/
                          #,亚太地区,2021-11-26,00:28:57,@17, https://www.gotporn.com/private-casting-x---music-vid-wannabe-gets-fucked/video-4790013
                          #,广西南宁市,2021-11-27,11:40:16, pornhub.com
                          brazzers.com
                          bang.com
                          xnxx.com
                          tube8.com
                          redtube.com
                          youjizz.com
                          youporn.com
                          pornpies.com
                          watchmygf.com
                          ikonwthatgirl.com
                          xvideos.com
                          xhamster.com
                          apetube.com
                          happyporn.com
                          realitykings.com
                          miakhalifa.com
                          momsteachsex.com
                          18andabused.com
                          chatterbate.io chatterbate.com
                          wetpussy.com
                          teenpornvideo.sex
                          pornmajor.
                          fakeporn.tv
                          http://jable.tv/
                          #,广西-南宁-中国电信,2021-12-11,00:00:18, http://www.cm404.com/
                          #,IANA,2021-12-19,01:45:33, http://www.cm529.com/list/index2.html
                          #,171.104.222.57, 121.9.232.190-InvalidIpAddress,2021-12-30,10:58:05, [StepSiblingsCaught] Step Sibling Fall Classic - Aria Lee
                          #,180.140.163.79, 121.9.232.179-InvalidIpAddress,2022-01-04,17:43:35, [REDLIGHT] オトナの絵本 赤ずきんちゃん(小红帽)汉化
                          [FOW-012][3DCG]Mila_Red_Riding_Hood
                          #,116.252.135.227, 45.251.102.96-InvalidIpAddress,2022-01-10,15:35:59, 1pondo Asaka Sera 世良あさか 100221_001 濃厚な接吻と肉体の交わり 世良あさか
                          #,116.252.135.227, 45.251.102.51-InvalidIpAddress,2022-01-10,15:48:33, 1pondo Nana Kamiyama 上山奈々 011621_001 まんチラの誘惑 〜和服姿のヤバい近所の奥さん〜
                          #,广西南宁市,2022-06-11,11:23:08, http://www.choisuntea.com/index.html
                          #,广西南宁市,2022-06-13,10:49:24, www.151py.com
                          #,广西南宁市,2022-06-18,11:45:05,@28, www.117py.com
                          #,广西南宁市,2022-06-18,12:14:08, http://www.zptianfeng.com/
                          #,广西南宁市,2022-06-18,12:22:23, http://www.99riav111.com/
                          #,广西南宁市,2022-06-18,12:49:43, http://99riav6.vip/
                          #,广西南宁市,2022-06-23,08:28:13, https://spankbang.com/2jzrn/video/milo+moir+mirror+box+uncensored
                          #,广西南宁市,2022-06-25,04:57:33,
                          magnet:?xt=urn:btih:ea41f8333793e812b0b63e96caa2aebe06258ec3&dn=Fap%20Hero%20Torrent%20Collection&tr=udp%3a%2f%2ftracker.openbittorrent.com%3a80&tr=udp%3a%2f%2ftracker.opentrackr.org%3a1337%2fannounce
                          Run code
                          Cut to clipboard
                            #,广西南宁市青秀区,2022-07-05,01:49:35, www.315py.com
                            #,广西南宁市,2022-07-13,08:33:46, 1桥本有腿2桃乃木香奈3天使萌?4美谷朱里5河北彩花6浜崎真绪?7三上悠亚8深田泳美9白桃花
                            文章:程序员编程常用网页工具集[游戏]  发表时间:2016-10-12, 22:22:12  
                            展开↯

                            #182

                            作者:广西南宁市
                            报错’<template v-for>’ cannot be keyed. Place the key on real elements instead
                            报错的使用场景
                            在vue3的项目中,不免会遇到v-if和v-for一起使用,但我们知道,这两个是不可以一起使用的,v-for 具有比 v-if 更高的优先级,所以我们需要把v-for写到template中,但是控制台会提示:

                            '<template v-for>' cannot be keyed. Place the key on real elements instead

                            解决方法
                            在 Vue 2中,<template> 标签不能拥有 key,不过,你可以为其每个子节点分别设置 key

                            <template v-for="i in list">
                            <div :key="'index-' + i.id"></div>
                            </template>

                            在 Vue 3 中,key 则应该被设置在 <template> 标签上

                            <template v-for="(i, index) in list" :key="index">
                            <div>...</div>
                            <span>...</span>
                            </template>

                            但是我在使用的时候VScode总是一直报错冒红,但是程序是可以运行的,但总看着不舒服,可以尝试将:key="index"写在我们循环的节点上面,程序也是可以运行的。

                            <template v-for="i in list">
                            <div v-if="true" :key="item.id"></div>
                            <span v-else></span>
                            </template>

                            按照官网说的key 则应该被设置在 <template> 标签上的话,可以修改.eslintrc.js的配置,在rules的规则上添加:

                            'vue/no-v-for-template-key': 'off'

                            或者将将template标签改为div等其他标签,这样的话会多出一个多余的div标签。
                            文章:vue生命周期详解  发表时间:2022-06-30, 10:09:48  
                            展开↯

                            #183

                            作者:广西南宁市
                            Deprecated: Directive ‘track_errors‘ is deprecated in Unknown on line 0
                            修改 php.ini track_errors=On 为 track_errors=Off 即可

                            The Windows OneDrive folder is not supported on PHP versions below 7.2.23 an
                            windows下安装composer

                            Could not find package topthink/think-worker. It was however found via repos
                            Composer更改为阿里的源
                            composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
                            Run code
                            Cut to clipboard

                              解除镜象
                              composer config -g --unset repos.packagist
                              Run code
                              Cut to clipboard


                                #,广西南宁市,2022-06-23,17:51:22,
                                解决PHP Warning: Module 'mysqli' already loaded in Unknown on line 0

                                原因:是PHP有两种方式添加扩展模块,一种是直接编译进了PHP,另外一种是通过共享模式添加模块,并在php.ini配置文件中配置相应的模块。以上问题出现的原因是我们需要的模块已经编译进PHP了,但是我们有通过共享模块再次加重了改模块,这样就导致重复加重。

                                在php.ini中找到下面并注释
                                ;extension=mysqli
                                Run code
                                Cut to clipboard


                                  使用php -m还是可以看到mysqli扩展的,并且不会再报刚才的错误
                                  文章:Thinkphp6配置使用Workerman WebSocket Socket  发表时间:2022-06-23, 17:50:23  
                                  展开↯

                                  #184

                                  作者:广西南宁市
                                  js获取audio语音时长
                                  //获取audio语音时长 function getVoiceTime() { $('ul.conversation li .outer-right audio.addVoiceTime').each(function () { var audio = $(this)[0], duration; audio.load(); audio.oncanplay = function(){ duration = Math.ceil(audio.duration); if (duration == 'Infinity') { getVoiceTime(); } else { console.log(duration + `''`); } } }); }
                                  Run code
                                  Cut to clipboard
                                    文章:开放免费的文本转语音接口  发表时间:2022-06-21, 15:36:10  
                                    展开↯

                                    #185

                                    作者:广西南宁市
                                    Vue实现音频文件播放功能 <el-button type="text" @click="handlePlay(scope.row)">播放</el-button> <el-dialog title="录音播放" :visible.sync="dialogVisible" width="20%" :before-close="stop"> <template> <center> <audio :src="src" autoplay="autoplay" controls="controls" ref="audio" >Your browser does not support the audio element.</audio> </center> </template> </el-dialog> <script> data() { return { src: "", dialogVisible: false, } methods: { //播放组件 handlePlay(row) { this.src = row.filePath; this.play(); }); }, //播放 play() { this.dialogVisible = true; this.$refs.audio.play(); }, //音频暂停 stop() { this.dialogVisible = false; this.$refs.audio.pause(); this.$refs.audio.currentTime = 0; } } </script>
                                    Run code
                                    Cut to clipboard
                                      文章:开放免费的文本转语音接口  发表时间:2022-06-21, 15:34:29  
                                      展开↯

                                      #186

                                      作者:广东省深圳市宝安区
                                      这博客有点东西
                                      #,广西南宁市,2022-06-13,10:45:26,
                                      文章:常用html、demo代码  发表时间:2022-06-10, 11:49:01  
                                      展开↯

                                      #187

                                      作者:广西南宁市
                                      创建配置文件
                                      // app/config/qiniu.php return [ 'ak' => '********************', // id 'sk' => '********************', // 秘钥 'bucket'=> '******', // 要上传的空间 'image_url' => '*************', // 空间域名 ];
                                      Run code
                                      Cut to clipboard


                                        创建上传到七牛的图片上传类
                                        // app/common/lib/QiUpload.php <?php namespace app\common\lib; use think\facade\Config; use Qiniu\Auth; use Qiniu\Storage\UploadManager; /** * Class QiUpload 图片上传至七牛云 */ class QiUpload { /** * 上传图片 * @param $request */ public static function qiUpload($request) { // 获取上传图片信息 $file = $request->file('file'); // 图片存储在本地的临时路经 $filePath = $file->getRealPath(); // 获取图片后缀 $ext = $file->getOriginalExtension(); // 上传到七牛后保存的新图片名 $newImageName = date('Y') . '/' . date('m') .'/' . substr(md5($file->getOriginalName()),0,6) . date('YmdHis') . rand(00000,99999) . '.'.$ext; // 说明:为了方便阅读,上一行代码进行的回车,如果你的遇到了问题,请放到一行 // 构建鉴权对象 $auth = new Auth(Config::get('qiniu.ak') , Config::get('qiniu.sk')); // 要上传的空间位置 $token = $auth->uploadToken(Config::get('qiniu.bucket')); // 初始化 UploadManager 对象并进行文件的上传。 $uploadMgr = new UploadManager(); list($ret , $err) = $uploadMgr->putFile($token , $newImageName , $filePath); if($err !== null){ return null; }else{ // 图片上传成功 return $newImageName; } } }
                                        Run code
                                        Cut to clipboard


                                          后台控制器使用
                                          // app/admin/controller/Test.php <?php namespace app\admin\controller; use think\facade\Config; use think\facade\View; use think\Request; use app\common\lib\QiUpload; class Test { public function index() { return View::fetch(); } public function add() { return View::fetch('add'); } // 图片上传 public function upload(Request $request) { if($request->isPost()){ $img = QiUpload::qiUpload($request); if($img){ // 图片完整绝对路经 $imgUrl = Config::get('qiniu.image_url') . '/' . $img; $data = [ 'status' => 1, 'msg' => '上传成功', 'img_url' => $imgUrl, ]; return json($data); }else{ return json(['status'=>0,'msg'=>'上传失败']); } } } }
                                          Run code
                                          Cut to clipboard

                                            文章:ThinkPHP6七牛云配置设置  发表时间:2022-06-09, 15:19:38  
                                            展开↯

                                            #188

                                            作者:广西南宁市
                                            #,广西南宁市,2022-06-08,21:03:33,
                                            文章:程序员编程常用网页工具集[游戏]  发表时间:2022-06-08, 21:02:55  
                                            展开↯

                                            #189

                                            作者:广西南宁市
                                            vscode顶部显示当前文件完整路径信息

                                            修改参数
                                              1. 搜索 window.title
                                            2. 将原来的值activeEditorShort 修改为 activeEditorLong


                                            vscode顶部即可显示文件完整路径
                                            若需要显示标签页中的面包屑功能
                                            View --> Toggle Breadcrumbs
                                            点击Toggle Breadcrumbs选项卡,即可实现标签页中面包屑的显示和隐藏

                                            文章:VSCode配置同步到git详细讲解  发表时间:2022-06-08, 17:59:34  
                                            展开↯

                                            #190

                                            作者:广西南宁市
                                            或者直接运行 命令列界面 粘贴 sql 运行
                                            #,广西南宁市,2022-06-08,17:58:01, [Err] [Dtf] 1067 - Invalid default value for 'time_pay'
                                            Navicat mysql 数据传输时如果提示[Err] [Dtf] 1067 - Invalid default value for ‘create_time‘ 数据同步 错误提示
                                            文章:mysql通过my.cnf修改默认字符集为utf-8的方法以及注意事项  发表时间:2021-07-22, 16:40:22  
                                            展开↯
                                            你好,残忍屏蔽广告

                                            确定要清除编辑框内容吗?

                                            该删除操作将不可恢复。

                                            删除 取消

                                            激活Windows

                                            转到"设置"以激活Windows。