我有一个关于codeigniter的项目,当我上传到cpanel并将文件上传到我的网站时,它现在在localhost上运行良好,显示 example.com 目前无法处理此请求。 HTTP错误500 为什么?谁能告诉我该怎么做?
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');
}
}
}
}
答案 0 :(得分:1)
检查system / libraries / upload.php 。 。 找到"受保护的函数_file_mime_type" 。 。 从
更改代码$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;
}
}
。 。 至 。
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;
}
}
}
。 。 我解决了我的错误,希望这也适合你,cmiiw