【问题标题】:Upload .exe file in WordPress website在 WordPress 网站上传 .exe 文件
【发布时间】:2016-12-20 04:51:05
【问题描述】:

我需要在我的 wordpress 网站上上传 .exe 文件。我已经添加了 define('ALLOW_UNFILTERED_UPLOADS', true);在我的 wp-config.php 文件中,但仍然显示相同的错误。请帮忙。 谢谢

【问题讨论】:

  • 无论您试图通过允许上传 EXE 来解决什么问题,都可能有一种更安全/更好的方法来解决。
  • @user1751825 想象一下,我想编写一个从我的 WP 网站下载安装程序的程序。
  • @EmilMocan 我的用例完全比设置单独的服务器更容易 - 可执行下载是整个网络的常见做法
  • 我实际上想添加代码格式,但尝试编辑它告诉我“标题不能包含“在 WordPress 网站上上传 .exe 文件”。请提供一个总结您的问题的标题。如需帮助,请参阅:How do I ask a good question?" - 这也是我推荐的内容

标签: wordpress


【解决方案1】:

感谢您的评论,下面的代码解决了我的问题,

function enable_extended_upload ( $mime_types =array() ) {

   // The MIME types listed here will be allowed in the media library.
   // You can add as many MIME types as you want.
   $mime_types['exe']  = 'application/exe'; 

   return $mime_types;
} 
add_filter('upload_mimes', 'enable_extended_upload');

【讨论】:

  • 将此添加到我的 functions.php 中,使用 wordpress 5.2 效果很好
【解决方案2】:

我遇到了同样的问题,the current answer 不再适合我。

以下在 wordpress 5.7.2 中适用于我(使用基本文件上传器测试):

wp-content/mu-plugins目录下新建一个.php文件,内容如下:

<?php

// specify a high priority so that the filter will run later
// there is a built in filter which will remove the entry for 'exe'
add_filter('upload_mimes', function($mimes) {
    // this mimetype has to match exactly what 
    // finfo_file() will return, see wp_check_filetype_and_ext()
    $mimes['exe'] = 'application/x-dosexec';
    return $mimes;
}, 10000);

【讨论】:

  • 我试过了,但它在 async-upload.php 的控制台中给出了 403 响应。会导致什么?
  • 您是否尝试过使用基本文件上传器(旧的)? Wordpress 有两个接口来上传文件。到目前为止,我还没有尝试为更现代的上传器制作这项工作。
  • 你的意思是在 /wp-admin/media-new.php 吗?
  • 原来我的服务器上传限制只有 64 MB
猜你喜欢
  • 2014-07-08
  • 2017-03-11
  • 2011-02-18
  • 2014-02-19
  • 1970-01-01
  • 2023-01-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多