js下载文件
普通的jQuery中的ajax请求后台,并不能处理Blob类型的数据,这里用的原生的XMLHttpRequest请求后台
转自:https://blog.csdn.net/lf1934305268/article/details/123401275
var xhr = new XMLHttpRequest();
xhr.open("get",url, true);
xhr.responseType = "blob";
xhr.onload = function() {
if (this.status == 200) {
$.unblockUI();
var blob = this.response;
if(blob.type == "text/html"){
return false
}
var fileName = "aaaa.xlsx";
if(window.navigator.msSaveOrOpenBlob){ // IE浏览器下
navigator.msSaveBlob(blob, fileName);
} else {
var link = document.createElement("a");
link.href = window.URL.createObjectURL(blob);
link.download = fileName;
link.click();
window.URL.revokeObjectURL(link.href);
}
}else{
}
}另:IE浏览器已不再使用,可以删除对IE浏览器的判断
我的代码:
var xhr = new XMLHttpRequest();
xhr.timeout = 600000; //设置超时毫秒数(0为永不超时)
xhr.open('GET', url, true);
xhr.responseType = 'blob';
xhr.onload = function(){
if(this.status != 200){
return;
}
var blob = this.response;
if(blob.type == "text/html"){
console.log('error');
return false;
}
var allow_type=['video/quicktime','video/mp4'];
if(allow_type.indexOf(blob.type)==-1){
console.log('content-type not allowed');
return false;
}
console.log(filename+' 下载完成,大小'+blob.size+'字节');
var url = window.URL.createObjectURL(blob);
var a = document.createElement('a');
a.href = url;
a.download = filename;
a.click();
window.URL.revokeObjectURL(a.href);
}
xhr.onerror = function(){
console.log('error');
console.log(this.status);
console.log(this);
}
xhr.ontimeout = function(){
console.log('timeout');
console.log(this.status);
console.log(this);
}
xhr.send();
localStorage简明教程
localStorage API(属性和方法):
length:返回 localStorage 中的键值对的数目
setItem():增加一个键值对到 localStorage 中
getItem():从 localStorage 中查询指定 key 的值
removeItem():从 localStorage 中删除指定的键值对
clear():清空 localStorage 中所有键值对
key(): 传入一个数字 n,用于返回指定第 n 个键的名字

PHP常用header状态
转自:https://www.cnblogs.com/limeng951/p/5634107.html
<?php
//200 正常状态
header('HTTP/1.1 200 OK');
// 301 永久重定向,记得在后面要加重定向地址 Location:$url
header('HTTP/1.1 301 Moved Permanently');
// 重定向,其实就是302 暂时重定向
header('Location: http://www.maiyoule.com/');
// 设置页面304 没有修改
header('HTTP/1.1 304 Not Modified');
// 显示登录框,
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="登录信息"');
echo '显示的信息!';
// 403 禁止访问
header('HTTP/1.1 403 Forbidden');
// 404 错误
header('HTTP/1.1 404 Not Found');
// 500 服务器错误
header('HTTP/1.1 500 Internal Server Error');
// 3秒后重定向指定地址(也就是刷新到新页面与 <meta http-equiv="refresh" content="10;http://www.jb51.net/ /> 相同)
header('Refresh: 3; url=http://www.jb51.net/');
echo '10后跳转到http://www.jb51.net';
// 重写 X-Powered-By 值
header('X-Powered-By: PHP/5.3.0');
header('X-Powered-By: Brain/0.6b');
//设置上下文语言
header('Content-language: en');
// 设置页面最后修改时间(多用于防缓存)
$time = time() - 60; //建议使用filetime函数来设置页面缓存时间
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT');
// 设置内容长度
header('Content-Length: 39344');
// 设置头文件类型,可以用于流文件或者文件下载
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="example.zip"');
header('Content-Transfer-Encoding: binary');
readfile('example.zip');//读取文件到客户端
//禁用页面缓存
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Pragma: no-cache');
//设置页面头信息
header('Content-Type: text/html; charset=iso-8859-1');
header('Content-Type: text/html; charset=utf-8');
header('Content-Type: text/plain');
header('Content-Type: image/jpeg');
header('Content-Type: application/zip');
header('Content-Type: application/pdf');
header('Content-Type: audio/mpeg');
header('Content-Type: application/x-shockwave-flash');
//.... 至于Content-Type 的值 可以去查查 w3c 的文档库,那里很丰富
?>Ueditor配置
1、宽度自适应:设置 initialFrameWidth: null
var ue = UE.getEditor('editor',{
initialFrameWidth:null, //宽度随浏览器自适应
wordCount: false, //关闭字数统计
elementPathEnabled : false, //隐藏元素路径
autoHeightEnabled: false, //是否自动长高
autoFloatEnabled: false, //是否保持toolbar的位置不动
allowDivTransToP: false, //阻止div标签自动转换为p标签
});2、高度自适应:设置 '#edui1' 和 '#edui1_iframeholder' 的高度
css中设置:
#edui1 {
height: 100%;
}js中设置(编辑器显示时):
$('#edui1_iframeholder').css('height','calc(100% - 10px)');3、扩展
ue.setDisabled();//不可编辑
设置页面不缓存的方法
转自:https://www.php.cn/php-ask-454686.html
一般我们要查看网上的一个网页,那么当您第一次访问这个网页的时候,系统首先要将这个网页下载到您的本地计算机的一个临时文件夹中进行缓存,当在一定的时间内,您第二次、第三次来访问这个网页的时候,浏览器就直接从您的本地计算机的临时文件夹中读取这个文件显示,这样做的好处就是避免每次都要重新下载而占用大量的时间和网络资源,不得不说页面的缓存加快了网页的显示,当然也有它的坏处,例如当服务器上的网页己经更新,而本地显示的还是没有更新的网页,这样就不能及时的显示更新后的内容,在某些情况下,我们需要禁止浏览器缓存,以使我们每次看到的页面都是最新的页面(例如后台操作、大型网站的实时新闻页面),这时我们就要禁用浏览器缓存,下面分别说明了在四种不同的页面环境下来禁止网页缓存:
一、对于静态页(就是通过meta标签来设置):
<!--expires用于设定网页的过期时间,一旦过期就必须从服务器上重新加载.时间必须使用GMT格式--> <meta http-equiv="expires" content="Sunday 26 October 2008 01:00 GMT" />
或者通过pragma no-cache来设置,pragma出现在http-equiv属性中,使用content属性的no-cache值表示是否缓存网页(为了提高速度一些浏览器会缓存浏览者浏览过的页面,通过下面的定义,浏览器一般不会缓存页面,而且浏览器无法脱机浏览)。
二、对于ASP页面:
<% Response.Buffer=true Response.CacheControl="no-cache" '禁止代理服务器缓存本页面 Response.Expires=-1000 '让页面立即过期(这儿最好设置一个绝对值较大的负数) %>
三、对于JSP页面:
<%
if(request.getProtocol().compareTo("HTTP/1.0")==0){
response.setHeader("Pragma","no-cache");
}
if(request.getProtocol().compareTo("HTTP/1.1")==0){
response.setHeader("Cache-Control","no-cache");
}
response.setDateHeader("Expires",0);
%>四、对于PHP页面:
<?php
header('Cache-Control:no-cache,must-revalidate');
header('Pragma:no-cache');
?>强调说明:对于动态页面,缓存的代码必须放在任何HTML标签输出之前,否则将会出错。
解决阿里云虚拟主机(linux系统)不支持中文文件名的问题
网站根目录有如下文件:

通过浏览器访问时,问题如下图:

原因 linux 系统文件名都是utf-8编码,所以只需要把文件名改为utf-8格式即可:
1、通过utf-8编码的php上传时,文件名会自动变为utf-8格式,而且看起来像乱码,如下:
此时可直接通过浏览器访问下载。
2、中文.docx,使用ftp工具上传到服务器后,文件名还是gbk编码,虽然看起来正常,但是通过浏览器访问时却是 404 Not Found。
echo convert_encoding('中文.docx', 'utf-8', 'gbk'); //GBK转UTF-8
人工复制生成的字符,重命名服务器上的文件,即可通过浏览器访问中文名称的文件了。
这只是提供一种思路,而且问题都是在"本地为WINDOWS系统,服务器为LINUX系统"的情况下遇到的。
微信公众号获取关注页面链接
第二步: 按住F12(window系统)打开代码审查 ,将代码全部复制出来放到一个新建的txt文件,全局搜索__biz,将后面跟的参数复制下来
第三步:将第二步获取的__biz参数放到下面位置 ,该链接即为关注页面的链接 本文发布于 2021-03-04 亲测有效
https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=这里第二步拿到的参数&scene=110#wechat_redirect
————————————————
版权声明:本文为CSDN博主「GreatClockZy」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_42645230/article/details/114372624
七牛云相关
七牛云PHP-SDK
https://github.com/qiniu/php-sdk
七牛云PHP-SDK示例
https://github.com/qiniu/php-sdk/tree/master/examples
七牛云图形化工具 Kodo Browser
https://developer.qiniu.com/kodo/5972/kodo-browser
七牛云文件下载链接
http://my-qiniu.abc.com/abc.jpg?attname=演示图片.jpg
需要在七牛云域名管理》缓存参数中设置保留 attname 参数,或保留全部参数
layui特殊方法
top.layui.index.openTabsPage(url,title);
关闭当前标签页:
window.top.layui.jquery('body').find('#LAY_app_tabs .layui-this .layui-tab-close').trigger('click');Layui Admin中关闭当前标签页:
parent.layui.admin.events.closeThisTabs();
在layer.open打开的iframe中关闭自己:
parent.layer.close(parent.layer.getFrameIndex(window.name));
头部工具栏
table.render({
toolbar: '#demoBar', //开启头部工具栏
defaultToolbar: ['filter','print','exports'], //默认工具栏
});获取表格全部数据
//方法1:包含接口返回的原始数据和组件内部的特定字段 table.cache[table_id]; //方法2:只包含接口返回的原始数据 table.getData(table_id);
浏览器用户脚本
Tampermonkey油猴
https://www.tampermonkey.net/
文档
https://www.tampermonkey.net/documentation.php?ext=dhdg
Tampermonkey中文文档
https://www.cnblogs.com/grubber/p/12560522.html
6个下载插件的神仙网站!
https://zhuanlan.zhihu.com/p/82397778
极简插件
https://chrome.zzzmh.cn/
安装教程
https://chrome.zzzmh.cn/index#help
欢迎来到 Greasy Fork,这里是一个提供用户脚本的网站
https://greasyfork.org/zh-CN
