【问题标题】:Unable to upload otf files using wordpress无法使用 wordpress 上传 otf 文件
【发布时间】:2018-09-07 09:29:37
【问题描述】:

我试图使用wp_handle_upload()在wordpress上传中上传字体文件

为了允许字体文件的类型,我在我的functions.php中添加了下面的代码

  function allow_font_mime_types($mimes) {
  $mimes['eot']   = 'application/vnd.ms-fontobject';
  $mimes['woff']  = 'application/font-woff'; 
  $mimes['otf']   = 'application/vnd.oasis.opendocument.formula-template';
  $mimes['svg']   = 'image/svg+xml';

  return $mimes;
}
add_filter('upload_mimes', 'allow_font_mime_types'); 

除了 otf 之外的所有文件都已上传。但是当我们尝试 uload otf 时,它会抛出错误

出于安全原因,不允许使用此文件类型

【问题讨论】:

    标签: php wordpress fonts upload


    【解决方案1】:

    您需要编辑您的 configure.php 文件。在上面加上这个小代码

    define( 'ALLOW_UNFILTERED_UPLOADS', true );
    

    要正确理解它,请遵循link

    【讨论】:

      【解决方案2】:

      我觉得对你有帮助

      $mimes['otf'] = 'application/font-sfnt';
      

      或者使用这个插件 - https://wordpress.org/plugins/use-any-font/

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-11-24
        • 2017-02-14
        • 1970-01-01
        • 2018-01-29
        • 2018-03-03
        • 1970-01-01
        • 2016-09-14
        • 2015-03-23
        相关资源
        最近更新 更多