3

WordPress 文件名 MD5 解决中文乱码问题

 2 years ago
source link: https://www.ixiqin.com/2017/07/10/wordpress-rename-file-upload/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

每次安装完成 WordPress,都会先添加这个函数,来确保我上传的文件不至于乱码,也分享给诸位。

  1. function new_filename($filename) {  
  2.     $info = pathinfo($filename);  
  3.     $ext = emptyempty($info[‘extension’]) ? ” : ‘.’ . $info[‘extension’];  
  4.     $name = basename($filename, $ext);  
  5.     return substr(md5($name), 0, 12) . $ext; //截取长度12  
  6. add_filter(‘sanitize_file_name’, ‘new_filename’, 10);  

本条目发布于2017年7月10日。属于技术分类,被贴了 WordPress 标签。

← 有道精品课倍速播放插件 Swift 是一门好语言 →

发表评论 取消回复

您的电子邮箱地址不会被公开。 必填项已用*标注

评论 *

显示名称 *

电子邮箱地址 *

网站地址

在此浏览器中保存我的显示名称、邮箱地址和网站地址,以便下次评论时使用。

如果有人回复我的评论,请通过电子邮件通知我。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK