Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 上载文件和内部服务器错误仅针对一个文件,其他文件正常_Php_File_Upload - Fatal编程技术网

Php 上载文件和内部服务器错误仅针对一个文件,其他文件正常

Php 上载文件和内部服务器错误仅针对一个文件,其他文件正常,php,file,upload,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 o

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

一切正常…但今天我上传后出错:

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个错误。。。没有向我显示调试信息

有什么问题吗?邪恶的文件

My 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();

}

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

此文件大小是否比您测试的其他文件大?如果是,您可以尝试上载另一个更大的文件吗?你可以访问php配置和服务器日志吗?@MaxChernopolsky Hi Max,文件大小不是问题。。。我上传了比这个更大的文件。是,这是日志错误:ModSecurity:拒绝访问,代码44(第2阶段)。需要将“等式0”与“多部分\u不匹配\u边界”匹配。[file”/etc/httpd/conf.d/mod_security.conf“][line“34”][id“200003”][msg“Multipart parser检测到可能不匹配的边界。”]So可能重复,mod_sequirity会阻止它。考虑关闭MODYSCONNECT OFF,否则,需要找出并配置它。