【发布时间】:2016-12-29 00:48:20
【问题描述】:
我的代码在 localhost 上运行良好,但是当我将文件上传到服务器时,我收到了这个错误 500 internal server error。
我的代码在这里:
上传方式
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;
}
}
任何帮助将不胜感激。谢谢
【问题讨论】:
-
A 500 通常意味着隐藏在其后面的错误,并且 500 仅用于防止显示任何敏感信息。添加
ini_set('display_errors', 1); ini_set('error_reporting', E_ALL),看看实际的错误是什么。 -
/uploads/可能不可写 -
error 500 内部服务器错误。这意味着您的
ajax调用错误。
标签: php codeigniter upload