Php 在codeigniter中上载文件时,显示网站当前无法处理此请求的原因。HTTP错误500
我有一个关于codeigniter的项目,它现在在localhost上运行得很好,当我在cpanel中上传一个文件到我的站点时,它显示example.com目前无法处理这个请求。HTTP错误500 为什么?谁能告诉我该怎么办Php 在codeigniter中上载文件时,显示网站当前无法处理此请求的原因。HTTP错误500,php,codeigniter,cpanel,Php,Codeigniter,Cpanel,我有一个关于codeigniter的项目,它现在在localhost上运行得很好,当我在cpanel中上传一个文件到我的站点时,它显示example.com目前无法处理这个请求。HTTP错误500 为什么?谁能告诉我该怎么办 public function doupload($id,$action) { $config['upload_path'] = 'SliderImages/'; $config['allowed_types'] = 'gi
public function doupload($id,$action)
{
$config['upload_path'] = 'SliderImages/';
$config['allowed_types'] = 'gif|jpg|png|jpeg|psd|pdf|tiff';
$config['overwrite'] = TRUE;
$config['encrypt_name'] = false;
$config['max_size'] = 10000000;
$config['max_width'] = 999999;
$config['max_height'] =99999;
$this->upload->initialize($config);
$files = $_FILES;
if($action == "insert")
{
if($_FILES['slide_image']['name'] !== '')
{
$_FILES['userfile']['name']= $files['slide_image']['name'];
$file_name = $_FILES['userfile']['name'];
$name =explode('.',$file_name);
$_FILES['userfile']['name'] = $id. '.' .$name[1];
$_FILES['userfile']['type']= $files['slide_image']['type'];
$_FILES['userfile']['tmp_name']= $files['slide_image']['tmp_name'];
$_FILES['userfile']['error']= $files['slide_image']['error'];
$_FILES['userfile']['size']= $files['slide_image']['size'];
//$this->upload->do_upload();
if (!$this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
return $error;
//print_r($error);die();
}
else
{
$msg = array('upload_data' => $this->upload->data());
return $this->upload->data('file_name');
}
}
}
}
检查system/libraries/upload.php . . 查找“受保护的函数\u文件\u mime\u类型” . . 从更改代码
$finfo = @finfo_open(FILEINFO_MIME);
if (is_resource($finfo)) // It is possible that a FALSE value is returned, if there is no magic MIME database file found on the system
{
$mime = @finfo_file($finfo, $file['tmp_name']);
finfo_close($finfo);
/* According to the comments section of the PHP manual page,
* it is possible that this function returns an empty string
* for some files (e.g. if they don't exist in the magic MIME database)
*/
if (is_string($mime) && preg_match($regexp, $mime, $matches))
{
$this->file_type = $matches[1];
return;
}
}
。
.
到
.
。
.
我解决了我的错误,希望这也能为你们工作,cmiiw好吧,试着检查服务器日志,或者至少激活php显示错误来了解更多关于你们的问题的细节。请检查你们服务器的php版本是否和你们的代码兼容。。因为我们有最新版本7.0,如果设置为最新版本,那么尝试将其设置为5.6 PHP版本index.PHP和其他文件的权限是什么?可能是755?是的,还有文件和文件夹权限
if (function_exists('finfo_file'))
{
$finfo = @finfo_open(FILEINFO_MIME);
if (is_resource($finfo)) // It is possible that a FALSE value is returned, if there is no magic MIME database file found on the system
{
$mime = @finfo_file($finfo, $file['tmp_name']);
finfo_close($finfo);
/* According to the comments section of the PHP manual page,
* it is possible that this function returns an empty string
* for some files (e.g. if they don't exist in the magic MIME database)
*/
if (is_string($mime) && preg_match($regexp, $mime, $matches))
{
$this->file_type = $matches[1];
return;
}
}
}