我在我的系统中使用Codeigniter(版本3)和图像上传功能。但是在GoDaddy服务器上运行时它无法正常工作。它在localhost和其他一些实时服务器上工作正常。只有在godadddy上它才能正常工作,之前它正在显示文件权限,所以我将完全控制权改为用户,现在它显示500错误。检查错误图片我尝试了很多方法,但无法获得解决方案。请帮帮我。
Codeigniter系统安装在主系统的文件夹中 www.mywebsite.com/admin
www.mywebsite.com/admin/.htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Options -Indexes
www.mywebsite.com/admin/Controller
function add_reports()
{
if($this->session->userdata('logged_in'))
{
$session_data = $this->session->userdata('logged_in');
$data['username'] = $session_data['username'];
$this->form_validation->set_rules('title', 'Title', 'required|xss_clean|trim|max_length[255]');
$this->form_validation->set_rules('description', 'Description', 'xss_clean|trim');
if (empty($_FILES['image']['name'])) {
$this->form_validation->set_rules('image', 'Image', 'required|max_lenght[100]');
}
$this->form_validation->set_error_delimiters('<div class="alert alert-success"><a class="close" data-dismiss="alert" aria-label="close">×</a>','</div>');
if ($this->form_validation->run() == FALSE) //If false redirect to createprofile
{
$data['report'] = $this->dashboard->reports();
$this->load->view('header',$data);
$this->load->view('reports');
$this->load->view('footer');
} else {
$url = 'home/reports';
$image = $this->image_upload_reports($url);
$pdf = $this->pdf_upload($url);
$checked = $this->input->post('active');
if((int) $checked == 1)
{
$active = 0;
} else {
$active = 1;
}
$this->dashboard->add_reports($image,$active,$pdf);
$this->session->set_flashdata('message','Report added');
redirect('home/reports');
}}
else{
redirect('');
}
}
function image_upload_reports($url){
if(isset($_FILES['image']['size']) != 0){
$name = date('Y-m-d H:i:s');
$upload_dir = '../img/';
//$upload_dir = '/home/***mywebsite.com***/public_html/img/';
if(!is_dir($upload_dir)) {
mkdir($upload_dir);
}
$config['upload_path'] = $upload_dir;
$config['allowed_types'] = 'jpg|png|jpeg';
$config['file_name'] = md5($name);
$config['overwrite'] = true;
$config['max_size'] = '200480'; // 2MB
$this->upload->initialize($config);
$path = $config['file_name'];
if (!$this->upload->do_upload('image')){
$error = array('error' => $this->upload->display_errors());
$this->session->set_flashdata('message','Image not uploaded. Please re-upload');
redirect($url);
}
else{
// $this->upload_data['file'] = $this->upload->data();
return $path.'.'.pathinfo($_FILES['image']['name'], PATHINFO_EXTENSION);
}
}
}