【发布时间】:2018-08-10 11:40:22
【问题描述】:
Wordpress 版本:4.7.9。
define('ALLOW_UNFILTERED_UPLOADS', true);
声明被写入wp-includes/functions.php。
编辑一个名为 test 的简单文件,该文件不包含任何扩展名。
vim test
to upload the file which contain no file extension.
上传文件test时报错。
This file type is not allowed. Please try another.
将文件test重命名为test.txt。
并将以下内容添加到wp-includes/functions.php。
add_filter('upload_mimes','custom_upload_mimes');
function custom_upload_mimes ( $existing_mimes=array() ) {
$existing_mimes['txt'] = 'application/txt';
return $existing_mimes;
}
文件test.txt可以上传成功。
在配置文件中设置wp-config.php是没有用的。
define('ALLOW_UNFILTERED_UPLOADS', true);
我正在使用一个 24 岁的孩子。
这是我的/var/www/html//wp-content/themes/twentyfourteen-child/functions.php
<?php
define('ALLOW_UNFILTERED_UPLOADS', true);
function my_theme_enqueue_styles() {
$parent_style = 'twentyfourteen-style'; // This is 'twentyfourteen-style' for the Twenty Fourteen theme.
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array( $parent_style ),
wp_get_theme()->get('Version')
);
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
remove_filter('the_content', 'wptexturize');
remove_filter('the_excerpt', 'wptexturize');
remove_filter('comment_text', 'wptexturize');
?>
它没有任何作用。
【问题讨论】:
-
那么,你想使用wordpress上传/验证功能吗?还是您的目标只是上传文件?
-
问题是什么?
-
无法上传不包含扩展名的文件,如何上传不包含扩展名的文件?
-
你在哪里上传文件?
-
Wordpress 没有输出类似“不允许此文件类型”的错误,我完全搜索了这个字符串,没有找到,您是通过媒体库上传的吗?也许这是您的服务器输出的错误消息?但我不能确定,但至少找不到那个字符串,这是肯定的(最新的 WP 版本)。