2020年8月

// PDF、text可以直接网页打开查看
// word、excel、ppt 文件可以通过office官方打开
$fileType = strrchr($fileUrl,'.');//获取文件类型
if($fileType == 'PDF' || $fileType =='txt'){
//直接网页中打开
}else if($fileType == 'doc' || $fileType =='docx' || $fileType =='xlsx' || $fileType =='xls'){
header('HTTP/1.1 301 Moved Permanently');
header('Location: https://view.officeapps.live.com/op/view.aspx?src='.$fileUrl);//fileUrl 必须是绝对路径
}

PHP下脚本

<!--[if lt IE 8]>
    <div class="browsehappy" role="dialog"><?php _e('当前网页 <strong>不支持</strong> 你正在使用的浏览器. 为了正常的访问, 请 <a href="http://browsehappy.com/">升级你的浏览器</a>'); ?>.</div>
<![endif]-->

HTML下脚本

<!--[if lt IE 8]>
    <div class="browsehappy" role="dialog">当前网页 <strong>不支持</strong> 你正在使用的浏览器. 为了正常的访问, 请 <a href="http://browsehappy.com/">升级你的浏览器</a>.</div>
<![endif]-->

常用thinkphp6轮子收集。

"topthink/framework": "^6.0.0",
"topthink/think-orm": "^2.0",
"topthink/think-multi-app": "^1.0",
"topthink/think-view": "^1.0",
"topthink/think-captcha": "^3.0",
"yurunsoft/pay-sdk": "^2.1",
"phpoffice/phpword": "^0.17.0",
"phpoffice/phpspreadsheet": "^1.11",
"topthink/think-image": "^1.0"

陆续更新中。

switch ($searchType) {
            case 'name':
                $res = OrdersModel::hasWhere('personBase',['name'=>$searchText])->paginate(100);
                break;
            case 'phone':
                $res = OrdersModel::hasWhere('personBase',['phone'=>$searchText])->paginate(100);
                break;
            case 'icard':
                $res = OrdersModel::hasWhere('personBase',['icard'=>$searchText])->paginate(100);
                break;
            case 'out_trade_no':
                $res = OrdersModel::with('personBase')->where(['out_trade_no'=>$searchText])->paginate(10);
                break;
            case 'transaction_id':
                $res = OrdersModel::with('personBase')->where(['transaction_id'=>$searchText])->paginate(10);
                break;
        }

错误提示

Access to XMLHttpRequest at 'http://localhost:8080/api/user/login' from origin 'http://localhost

解决方案

1. HTML 页面

ajax 请求加入 contentType: "application/x-www-form-urlencoded"

请求如下:

$.ajax({
            type: "post",
            url: 'url',
            contentType: "application/x-www-form-urlencoded",
            data: {"gameCode": 106, type: "2",version:1,uid:1},
            dataType: "json",
            success: function (data,status) {
                console.log(data);
            }
        });

2. php 程序

PHP 文件中加入请求头部 header ('Access-Control-Allow-Origin: *') ;
<?php 
    header('Access-Control-Allow-Origin: *');
    $arr = [
        array('id'=>1,'title'=>'one1'),
        array('id'=>2,'title'=>'one2'),
        array('id'=>3,'title'=>'one3'),
        array('id'=>4,'title'=>'one4'),
    ];
    echo json_encode($arr);
 ?>

3. ajax 请求数据

请输入图片描述
————————————————
原文作者:PHPer技术栈
转自链接:https://learnku.com/articles/32041#b0756c
版权声明:著作权归作者所有。商业转载请联系作者获得授权,非商业转载请保留以上作者信息和原文链接。

$.ajax({
url: "/Ajax/System/ajaxcheshi.ashx",
dataType:'text',   //  datatype: "json", 
type: "post",
data:user,//,quenceAge=quenceAge,ctertime=ctertime,tquencether=tquencether,Status=Status}
success: function (data) {
    if (data == "1") {
        alert("保存成功");
        // window.location.href = "ModelDatasequence.aspx";
        // location.href = "ModelDatasequence.aspx";
        // window.location.href="http://www.hao123.com";
        //   $this.redirect("Management/ModelDatasequence.aspx");
        setTimeout("javascript:location.href='ModelDatasequence.aspx'", 0);
    } else {
        alert("保存失败");
    }
});

解决方案 把你的 type="submit" 换成type="button"
本文转自:https://www.cnblogs.com/lzhicheng/p/8637471.html

特别是网站根目录下面出现index.php不太友好,下面修改办法:

Apache的伪静态设置,如下


Options +FollowSymlinks -Multiviews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
\#RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]

windows下用记事本在网站根目录下面新建保存为.htaccess文件即可。