首页 > 新闻资讯 > 突破上传文件类型限制

突破上传文件类型限制

12条评论
标签:
更多

把这段代码添加到主题的functions.php里面,将可以突破一系列上传文件类型的限制,比如添加在行列里面添加"png",就可以上传png格式的图片 

1    add_filter('upload_mimes','restrict_mime');
2    function restrict_mime($mimes) {
3    $mimes = array(
4                    'jpg|jpeg|jpe' => 'image/jpeg',
5                    'gif' => 'image/gif',
6    );
7    return $mimes;
8    }

* 版权声明:作者WordPress啦! 转载请注明出处。

#1
谢谢分享,不过,一般都够用了!
#2
收藏
#3
哇,这么小一段代码就能办到吗?收藏 了。
#4
这个不是很熟了
#5
这个代码不错了
#6
很有意义的分享,谢谢
#7
我的升PR2了,哈哈
#8
一般不喜欢修改代码
#9
感谢分享!!!
#10
特殊的用处会用在特殊的地方,现在暂时还用不上。
#11
这个方法就行了试试
#12
this site have helped me lot. i highly recommend it to others. i really enjoyed this site

发表新评论

此内容将保密,不会被其他人看见。
  • 自动将网址与电子邮件地址转变为链接。
  • 允许HTML标签:<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • 自动断行和分段。

更多关於格式化选项的信息

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.