php - 只有一个文件上传文件和内部服务器错误,其他都可以

标签 php file upload

我有一个奇怪的问题。 我有一个上传文件的表格。

一切正常...但是今天上传后出现错误:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator to inform of the time the error occurred and of anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

经过一些测试,我发现问题只出在我的一个文件上!

此文件为 PDF。

我尝试重命名它。没有成功。 我尝试通过服务在线检查它是否是有效的 PDF……它是有效的。 文件没有损坏(我可以查看)

如果我压缩并上传一切正常。 其他文件都可以上传....只有这个特定的文件导致 500 错误!

我还插入了:

ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);

在 index.php 页面的开头...但我总是收到 500 错误...没有向我显示任何调试信息...

可能是什么问题?恶意文件?

我的index.php是一个标准的上传脚本:

<?php

ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);

// if I UNCOMMENT THIS 2 LINES, STILL GET 500 ERROR...VERY STRANGE AT THIS POINT
//var_dump($_FILES);
//exit();


if ( isset($_POST['action']) && $_POST['action'] == "upload" ) {

    if ( isset($_FILES['file']) ) {

        $upload = upload_file($_FILES['file']); //<-- my custom function to save to disk

        if ( !$upload['Error'] ) {

            // do some stuff

        }

    }

    header("Location: ../");
    exit();

}

更新:一些信息。如果我在带有 WAMP 服务器的本地主机上尝试一切正常。在线使用时出现错误

更新 2:这不是文件大小问题。该问题仅出现在一个特定的服务器中......在其他服务器中一切正常:这是来自服务器的日志错误:ModSecurity:代码 44 拒绝访问(第 2 阶段)。需要“eq 0”与“MULTIPART_UNMATCHED_BOUNDARY”的匹配。 [文件“/etc/httpd/conf.d/mod_security.conf”] [行“34”] [id“200003”] [消息“多部分解析器检测到可能不匹配的边界。”]

最佳答案

该特定服务器的 (ModSecurity) 上传的最大大小是多少问题仅出现在一个特定服务器

关于php - 只有一个文件上传文件和内部服务器错误,其他都可以,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57196164/

相关文章:

php - 查询未插入数据库

php - 从sql获取时格式化时间

javascript - 如何使用 .map 重新格式化将 php 数组转换为 js 数组

java - 查找数组中的重复项并仅打印一次

Tridion 内容管理器中的上传文件夹丢失

PHP/MySQL 在数据库中交换位置 + JavaScript (jQuery)

file - 如何在matlab中读取文件?

python - 通过文件夹/文件属性获取主机名

选择文件时Javascript调整图像大小并上传新图像而不是原始图像

php - 使用 PHP 在 Oracle 中将图像作为 BLOB 上传