上传文件在服务器响应500内部服务器错误Codeigniter 3
问题描述:
我的代码在本地主机上正常工作,但是当我上传文件到服务器时,我得到这个错误500内部服务器错误。上传文件在服务器响应500内部服务器错误Codeigniter 3
我的代码是在这里:
上传方法
public function do_upload($fieldname)
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'jpg|png';
$config['max_size'] = 10000;
/*$config['max_width'] = 1024;
$config['max_height'] = 768;*/
//echo '<pre>'; print_r($config); exit; //this array responding Ok but the issue is in the bottom codintion.
$this->load->library('upload', $config);
if (! $this->upload->do_upload($fieldname))
{
$error = array('condition'=>'error', 'error' => $this->upload->display_errors());
return $error;
}
else
{
$data = array('condition'=>'success', 'upload_data' => $this->upload->data());
return $data;
}
}
任何帮助将不胜感激。由于
答
而不是
$config['upload_path'] = './uploads/';
尝试使用完整的路径:例如/var/www/public_html/uploads
$config['upload_path'] = $_SERVER['DOCUMENT_ROOT'] . '/uploads/';
此外,还要确保您的/uploads/
目录有写入
+0
谢谢@zanderwar,我尝试了所有这些方法,但没有得到任何积极的回应。 –
+0
好吧,您需要追踪PHP在致命错误中生成的'error_log'。 – zanderwar
一个500通常意味着那里有一个错误躲在背后和500只是起到了防止被显示的任何敏感信息。添加'ini_set('display_errors',1); ini_set('error_reporting',E_ALL)'看看实际的错误是什么。 – zanderwar
'/ uploads /'可能不可写入 – zanderwar
错误500内部服务器错误。它表示在您的'ajax'调用时出现错误。 –