• <i id='fV2wS'><tr id='fV2wS'><dt id='fV2wS'><q id='fV2wS'><span id='fV2wS'><b id='fV2wS'><form id='fV2wS'><ins id='fV2wS'></ins><ul id='fV2wS'></ul><sub id='fV2wS'></sub></form><legend id='fV2wS'></legend><bdo id='fV2wS'><pre id='fV2wS'><center id='fV2wS'></center></pre></bdo></b><th id='fV2wS'></th></span></q></dt></tr></i><div id='fV2wS'><tfoot id='fV2wS'></tfoot><dl id='fV2wS'><fieldset id='fV2wS'></fieldset></dl></div>
    <legend id='fV2wS'><style id='fV2wS'><dir id='fV2wS'><q id='fV2wS'></q></dir></style></legend>

      <tfoot id='fV2wS'></tfoot>

      <small id='fV2wS'></small><noframes id='fV2wS'>

        • <bdo id='fV2wS'></bdo><ul id='fV2wS'></ul>

        上传文件时禁止 Apache 403

        Apache 403 Forbidden When Uploading Files(上传文件时禁止 Apache 403)
      1. <legend id='x3UFS'><style id='x3UFS'><dir id='x3UFS'><q id='x3UFS'></q></dir></style></legend>
      2. <small id='x3UFS'></small><noframes id='x3UFS'>

          <tbody id='x3UFS'></tbody>
            • <bdo id='x3UFS'></bdo><ul id='x3UFS'></ul>

                • <i id='x3UFS'><tr id='x3UFS'><dt id='x3UFS'><q id='x3UFS'><span id='x3UFS'><b id='x3UFS'><form id='x3UFS'><ins id='x3UFS'></ins><ul id='x3UFS'></ul><sub id='x3UFS'></sub></form><legend id='x3UFS'></legend><bdo id='x3UFS'><pre id='x3UFS'><center id='x3UFS'></center></pre></bdo></b><th id='x3UFS'></th></span></q></dt></tr></i><div id='x3UFS'><tfoot id='x3UFS'></tfoot><dl id='x3UFS'><fieldset id='x3UFS'></fieldset></dl></div>
                • <tfoot id='x3UFS'></tfoot>
                  本文介绍了上传文件时禁止 Apache 403的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  当我提交带有输入文件的 multipart/form-data 表单时,我遇到了一个奇怪的 apache 错误.似乎只有当我上传 70kb 或更大的文件时才会发生这种情况.

                  I'm having a strange apache error when I submit a multipart/form-data form with an input file. It seems that only happens when I upload files 70kb or bigger.

                  这是我的 php.ini 设置:

                  Here are my php.ini settings:

                  file_uploads = On
                  upload_max_filesize = 10M
                  max_execution_time = 90
                  max_input_time = 90
                  memory_limit = 196M
                  post_max_size = 10M
                  

                  这是 test.php 中的 HTML:

                  Here is the HTML in test.php:

                  <form action=""  method="POST" enctype="multipart/form-data">
                      <input type="file" name="pdfMagazine" />
                      <input type="submit" value="Save" name="saveMagazine" />
                  </form>
                  

                  这是错误:

                  Forbidden
                  
                  You don't have permission to access /test.php on this server.
                  
                  Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
                  
                  Apache/2.2.24 (Unix) mod_ssl/2.2.24 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 Server at myserver.com Port 80
                  

                  以下是有关环境的更多详细信息:

                  Here's some more details about the environment:

                  • Apache 没有安装 mod_security,没有 .htaccess 限制文件上传
                  • 仅记录存在 403 代码的点
                  • 我试过的test.php权限是755和644
                  • 如果没有上传文件,表单提交正常.

                  谁能帮帮我?

                  提前致谢.

                  [更新]

                  看来服务器确实安装了 mod_security,这里是 apache 原始日志:

                  It appears that server does have mod_security installed, here is apache raw log:

                  [Wed Jun 12 19:48:01 2013] [error] [client x.x.x.x] mod_security: Access denied with code 403. read_post_payload: Failed to create file "/root/tmp/20130612-194801-190.115.8.74-request_body-deJpho" because 13("Permission denied") [severity "EMERGENCY"] [hostname "myserver.com"] [uri "/test.php"]
                  [Wed Jun 12 19:48:01 2013] [error] [client x.x.x.x] mod_security: sec_filter_in: Failed to open file "/root/tmp/20130612-194801-190.115.8.74-request_body-deJpho" [hostname "myserver.com"] [uri "/403.shtml"]
                  

                  做研究我发现了这个:

                  **Upload tmpdir issues**
                  
                  Seeing this?
                  
                  <source lang='php'> [Fri Nov 18 14:49:50 2011] [error] [client 72.52.142.215] mod_security: Access denied with code 406. read_post_payload: Failed to create file "/root/tmp/20111118-144950-72.52.142.215-request_body-xGPNPd" because 13("Permission denied") [severity "EMERGENCY"] [hostname "lakedonpedro.org"] [uri "/wp-cron.php?doing_wp_cron"] [unique_id "TsbhJkg0jtcAACYIFDk"] </source>
                  
                  This actually happens because PHP's being set to use /root/tmp and the upload tmp dir. Let's set a few things then! Yay!
                  
                  Make sure these are all set in /usr/local/lib/php.ini (session.save_path will probably already be set)
                  upload_tmp_dir = /tmp
                  session.save_path = /tmp
                  
                  Make sure these are all set in /usr/local/apache/conf/modsec2.user.conf (or the applicable file for your system)
                  SecUploadDir /tmp
                  SecTmpDir /tmp
                  
                  Restart the apachies.
                  It also seems it has worked adding the above to modsec.conf corrects this issue. per ~awilson
                  

                  我确实更改了 php.ini,但 modsec 配置文件有一个很大的警告,只有服务器提供商可以编辑它,所以我正在联系他们.

                  I did change the php.ini but the modsec configuration file has a big warning that only servers provider can edit it so I'm contacting them.

                  我会让你知道发生了什么.

                  I'll let you know what happend.

                  [已解决]

                  Apaches 模块 mod_security 默认有 60kb 的上传限制,所以任何更大的上传都会抛出 403 错误代码.

                  Apaches module mod_security has a 60kb upload limit by default so any bigger upload will throw a 403 error code.

                  由于 modsec.conf 只能由服务器提供商编辑,我将以下行添加到每个根 .htaccess:

                  As the modsec.conf is only editable by the server provider, I add the following line to every root .htaccess:

                  SecFilterEngine Off
                  

                  这通常会关闭 mod_security 过滤器.

                  That turned off the mod_security filter in general.

                  推荐答案

                  Apaches 模块 mod_security 默认有 60kb 的上传限制,所以任何更大的上传都会抛出 403 错误代码.

                  Apaches module mod_security has a 60kb upload limit by default so any bigger upload will throw a 403 error code.

                  由于 modsec.conf 只能由服务器提供商编辑,我将以下行添加到每个根 .htaccess:

                  As the modsec.conf is only editable by the server provider, I add the following line to every root .htaccess:

                  SecFilterEngine Off
                  

                  这通常会关闭 mod_security 过滤器.

                  That turned off the mod_security filter in general.

                  这篇关于上传文件时禁止 Apache 403的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  PHP Upload File Validation(PHP 上传文件验证)
                  PHP Error - Uploading a file(PHP 错误 - 上传文件)
                  How can I write tests for file upload in PHP?(如何在 PHP 中编写文件上传测试?)
                  php resizing image on upload rotates the image when i don#39;t want it to(php在上传时调整图像大小会在我不想要它时旋转图像)
                  How to send additional data using PLupload?(如何使用 PLupload 发送附加数据?)
                  change button text in js/ajax after mp4 =gt;mp3 conversion in php(在 php 中的 mp4 =gt;mp3 转换后更改 js/ajax 中的按钮文本)

                  <small id='JPqzV'></small><noframes id='JPqzV'>

                    • <bdo id='JPqzV'></bdo><ul id='JPqzV'></ul>

                    • <tfoot id='JPqzV'></tfoot>
                        <legend id='JPqzV'><style id='JPqzV'><dir id='JPqzV'><q id='JPqzV'></q></dir></style></legend>

                          <i id='JPqzV'><tr id='JPqzV'><dt id='JPqzV'><q id='JPqzV'><span id='JPqzV'><b id='JPqzV'><form id='JPqzV'><ins id='JPqzV'></ins><ul id='JPqzV'></ul><sub id='JPqzV'></sub></form><legend id='JPqzV'></legend><bdo id='JPqzV'><pre id='JPqzV'><center id='JPqzV'></center></pre></bdo></b><th id='JPqzV'></th></span></q></dt></tr></i><div id='JPqzV'><tfoot id='JPqzV'></tfoot><dl id='JPqzV'><fieldset id='JPqzV'></fieldset></dl></div>
                              <tbody id='JPqzV'></tbody>