【问题标题】:Apache error Directory index forbidden by ruleApache错误目录索引被规则禁止
【发布时间】:2011-04-13 19:27:30
【问题描述】:

我收到以下错误:

 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';
} 
 } 

 }

【问题讨论】:

  • 您的 mod_rewrite 规则似乎无法正常工作。

标签: php apache codeigniter


【解决方案1】:

我解决了这个问题,我忘记了 Mac 网络共享

【讨论】:

    猜你喜欢
    • 2018-10-16
    • 2016-06-19
    • 1970-01-01
    • 2014-02-06
    • 1970-01-01
    • 2013-09-03
    • 2013-10-17
    • 2020-11-26
    • 1970-01-01
    相关资源
    最近更新 更多