Apache错误规则禁止的目录索引

时间:2011-04-13 19:27:31

标签: php apache codeigniter

我收到以下错误:

 Directory index forbidden by rule: /Users/User/Desktop/Local/House/includes/uploads/gallery/, referer: http://house.dev.local/admin/deleteimage

的.htaccess

# Customized error messages.
 ErrorDocument 404 /index.php

 # Set the default handler.
DirectoryIndex index.php

# Various rewrite rules.
 <IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond $1 !^(index\.php|css|js|images|files|scripts|robots\.txt)
 RewriteRule ^(.*)$ index.php/$1 [L,QSA]
 </IfModule> 

删除图片

if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Addimage extends CI_Controller { 

function __construct(){ 
parent::__construct(); 
} 
function index() { 
if(!$this->session->userdata('logged_in')) { 
    redirect('admin/home'); 
} 
// Main Page Data 
$data['cms_pages'] = $this->navigation_model->getCMSPages(); 
$data['title'] = 'Add Gallery Image'; 
$data['content'] = $this->load->view('admin/addimage',NULL,TRUE); 

$this->load->view('admintemplate', $data); 

//Set Validation 
//$this->form_validation->set_rules('userfile', 'userfile', 'trim|required'); 
$this->form_validation->set_rules('description', 'Description', 'trim|required'); 

if($this->form_validation->run() === TRUE) { 

//Set File Settings 
$config['upload_path'] = 'includes/uploads/gallery/'; 
$config['allowed_types'] = 'jpg|png'; 
$config['remove_spaces'] = TRUE;
$config['overwrite'] = TRUE;
$config['max_size'] = '100'; 
$config['max_width'] = '1024'; 
$config['max_height'] = '768'; 

$this->load->library('upload', $config);
if(!$this->upload->do_upload()) {

$error = array('imageError' => $this->upload->display_errors());
}
else{
$data = array('upload_data' => $this->upload->data());
$config['image_library'] = 'GD2';
$config['source_image'] = $this->upload->upload_path.$this->upload->file_name;
$config['new_image'] = 'includes/uploads/gallery/thumbs/';
$config['create_thumb'] = 'TRUE';
$config['thumb_marker'] ='_thumb';
$config['maintain_ratio'] = 'FALSE';
$config['width'] = '200';
$config['height'] = '150';

$this->load->library('image_lib', $config);
$this->image_lib->resize();
}

$file_info = $this->upload->data();

$data = array(   
    'description' => $this->input->post('description', TRUE), 
    'fullpath' => $file_info['file_name'],
'thumbpath' =>$file_info['raw_name'].'_thumb'.$file_info['file_ext'] 
    ); 
$this->image_model->addImage($data);

$this->data['success'] = 'Thank You, Your Image Has Been Uploaded';
} 
 } 

 }

1 个答案:

答案 0 :(得分:-1)

我解决了这个问题,我已经忘记了mac web共享