Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/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 上传多张图片导致500错误_Php_Codeigniter_File Upload_Mod Security - Fatal编程技术网

Php 上传多张图片导致500错误

Php 上传多张图片导致500错误,php,codeigniter,file-upload,mod-security,Php,Codeigniter,File Upload,Mod Security,我修改了我在这里找到的一个脚本来处理一次上传的多张图片。但是,当我尝试运行脚本时,它会抛出一个错误。我过去的脚本只允许一次上传一张图片,效果很好,没有任何问题 这是我的密码 Function uploadMultiple(){ $config = array( 'allowed_types' => 'jpg|png|jpeg|gif', 'upload_path' => $this->board_path, 'overwr

我修改了我在这里找到的一个脚本来处理一次上传的多张图片。但是,当我尝试运行脚本时,它会抛出一个错误。我过去的脚本只允许一次上传一张图片,效果很好,没有任何问题

这是我的密码

Function uploadMultiple(){
    $config = array(
        'allowed_types' => 'jpg|png|jpeg|gif',
        'upload_path' => $this->board_path,
        'overwrite' => false,
        //'file_name' => $fileName

    );
    //print_r($config);

    $this->load->library('upload');
    $errorCount = 0;
    $results = array(
        'errorsPresent' => false,
    );
    $successCount = 0;

    //for each image...try to upload.  if it fails, add it to the error list.
    //keep a list of successful uploads.
    print_r($_FILES);
    for ($i = 0; $i<count($_FILES); $i++){
        echo 'here';
        $_FILES['userfile']['name']    = $_FILES['userfile' . $i]['name'];
        $_FILES['userfile']['type']    = $_FILES['userfile' . $i]['type'];
        $_FILES['userfile']['tmp_name'] = $_FILES['userfile' . $i]['tmp_name'];
        $_FILES['userfile']['error']       = $_FILES['userfile' . $i]['error'];
        $_FILES['userfile']['size']    = $_FILES['userfile' . $i]['size'];

        $config['file_name']     = 'img_' . time() . '.png'; //inserts the unix time into the file name.
        $config['upload_path']   = $this->board_path;
        $config['allowed_types'] = 'jpg|jpeg|gif|png';
        $config['max_size']      = '0';
        $config['overwrite']     = FALSE;
        $this->upload->initialize($config);

        if ( ! $this->upload->do_upload()){
            $results['errorsPresent'] = true;
            $results['error'][$errorCount] = $this->upload->display_errors();
            $errorCount ++;

        } else {
            $data = array('upload_data' => $this->upload->data());              
            $pictureData = $this->upload->data();
            $file_location = $pictureData['full_path'];
            $file_location = substr($file_location, 18);//this should probably be dynamic...
            $file_location = $this->db->escape($file_location);
            $results['success'][$successCount] = $file_location;

            chmod($pictureData['full_path'], 777); //don't need to give it execute permissions but oh well.
            $successCount ++;       
        }

    }

    return $results;
}
函数uploadMultiple(){
$config=array(
“允许的_类型”=>“jpg | png | jpeg | gif”,
“上传路径”=>$this->board\u路径,
“覆盖”=>false,
//“文件名”=>$fileName
);
//打印(配置);
$this->load->library('upload');
$errorCount=0;
$results=数组(
'errorsPresent'=>错误,
);
$successCount=0;
//对于每个图像…尝试上载。如果失败,请将其添加到错误列表中。
//保留成功上载的列表。
打印(美元文件);
对于($i=0;$iboard\u路径;
$config['allowed_types']='jpg | jpeg | gif | png';
$config['max_size']='0';
$config['overwrite']=FALSE;
$this->upload->initialize($config);
如果(!$this->upload->do_upload()){
$results['errorsPresent']=true;
$results['error'][$errorCount]=$this->upload->display_errors();
$errorCount++;
}否则{
$data=array('upload_data'=>$this->upload->data());
$pictureData=$this->upload->data();
$file_location=$pictureData['full_path'];
$file_location=substr($file_location,18);//这可能是动态的。。。
$file\u location=$this->db->escape($file\u location);
$results['success'][$successCount]=$file\u位置;
chmod($pictureData['full_path',777);//不需要给它执行权限,但是很好。
$successCount++;
}
}
返回$results;
}
这是500错误

内部服务器错误

服务器遇到内部错误 错误或配置错误,并且 无法完成您的请求

请与服务器联系 管理员webmaster@localhost和 通知他们错误发生的时间 发生了什么,还有你可能发生的任何事情 这样做可能会导致错误

有关此错误的详细信息,请参阅 可以在服务器错误日志中找到

另外,一台500的内部服务器 运行时遇到错误 试图使用ErrorDocument来 处理请求

这是apache日志文件所说的:

[Wed Mar 23 02:29:41 2011][error][client 129.21.129.32]ModSecurity:使用代码500拒绝访问(第4阶段)。模式匹配“(?:\b(?:(?:s(?:elect list),因为它不包含在(?:聚合函数中,并且没有聚合函数或GROUP BY子句,|提供的参数无效(?:(?:M(?:s(?;y)| Postgre)SQL |O(?:racle | DBC))| S(?:yntax error converti…“在响应体。[文件“/etc/apache2/conf.d/modsecurity/modsecurity_crs 50_outbound.conf”][line“23”][id“970003”][msg“SQL信息泄漏”][severity“WARNING”][tag learning/ERRORS”][hostname“hostname.com”][uri uri uri longboard/index.php/board/add”][unique"id“Tvyegwgwyaaaaskoaaaaaaj]

根据错误消息,我认为modsecurity出于某种原因阻止了脚本,但我不确定原因。如果您有任何见解,我们将不胜感激


谢谢

尝试禁用mod_安全功能, 在.htaccess中添加此

SecFilterEngine Off

这最终是一个数据库错误。Mod_security阻止了错误消息。我进入Mod_security日志文件,找到了导致它抛出500错误的规则。然后我使用该规则进入该文件并将其注释掉。我重新启动了apache并重新测试,然后显示了数据库错误。我正在考虑离开此rule评论说,这是一个开发服务器。(虽然它向全世界广播,但这也是我安装Mod_security的原因。)

你能在这里发布
$results
变量吗?页面错误为500错误,因此我的echo或print语句都不打印。