该请求已被拒绝 [英] The request has been black-holed

查看:93
本文介绍了该请求已被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我上传多个图像时,我发现请求已被黑洞
错误:在此服务器上找不到所请求的地址'/ admins / uploadimage1'。

when i am upload multiple images i found The request has been black-holed Error: The requested address '/admins/uploadimage1' was not found on this server.

我的控制器功能

public function uploadimage1()
{
    if($this->request->is('post'))
    {
    $a=$this->data['Admins']['imgs'];
    print_r($a);
}
}

查看文件

<?php echo $this->Form->create('Admins',array('controller'=>'Admins','action'=>'uploadimage1', 'type'=>'file', 'accept-charset'=>'utf-8'));?>
        <table width="95%">
            <tr><td><b>Image Title</b></td><td><?php echo $this->Form->input('title', array('type' => 'text', 'class'=>'input-block-level','placeholder'=>'Image Title' ,'label'=>false )); ?></td></tr>
            <tr><td></td><td>

            <?php echo $this->Form->input('imgs.',array('type'=>'file', 'label'=>false, 'multiple')); ?></td></tr>
            <tr><td></td><td><?php echo $this->Html->image('../img/adminimages/upload.jpg', array('id'=>'blah','height'=>'100px','width'=>'100px')); ?></td></tr>
          <tr><td></td><td>
          <?php 
            foreach ($Retailers as $Retailer)
            {
                $r_id=$Retailer['Retailer']['id'];
            echo $this->Form->input('r_id', array('type'=>'hidden','value'=>$r_id)); }?>
              <?php echo $this->Form->submit('Submit',array('class' => 'button')); ?></td></tr></table>

            <?php echo $this->Form->end();

我的控制器

<?php


App::uses('AppController', 'Controller');


class AdminsController extends AppController 
{


    public $name='Storelocators/Admins';

/**
 * This controller does not use a model
 *
 * @var array
 */
    public $uses = array('Admin','Retailer','Gallery');

    public function beforeFilter() {

        $this->Security->unlockActions = ('uploadimage1');
        $this->Auth->allow('login','logout','signup','abhi');
    }

    public function beforeRender() {
        parent::beforeRender();
    }

    public function index() 
    {
        $this->layout='admin';

    }

    public function signup()
    {
            $this->layout='admin';          
                    if($this->request->is('post'))
        {

                    $admin_data=array (
                    'username'=>$this->data['Admins']['username'],
                    'email'=>$this->data['Admins']['email'],
                     'type'=>'Admin',
                    'password'=>$this->Auth->password($this->data['Admins']['password']));

                    $this->Admin->save($admin_data);
                        $this->Session->setFlash(__('Your are successfully Sign up.', true), 'default', array('class' => 'sukses'));    



           $this->redirect($this->referer());
        }
    }


        public function login(){
        $this->layout='admin';
        if($this->request->is('post')){
                    if($this->Auth->login()){   
                    $name = $this->Auth->user('username');

                  $this->Session->write('a', $name);  

                $this->redirect($this->Auth->redirect());

                }

            else{
                $this->Session->setFlash(__("Your email/password combination was incorrect.", true));
                $this->redirect($this->referer());


            }
        }
    }

    public function logout(){
        $this->Session->delete('a');
        $this->layout = false;
        $this->autoRender = false;  
        $this->Session->setFlash(__('You have logout successfully.', true), 'default', array('class' => 'message success'));
        $this->redirect($this->Auth->logout());
    }

    public function form()
    {
        $this->layout='admin';
        if($this->request->is('post'))
        {
            if(!empty($this->data['Admins']['imgs']['name']) && !empty($this->data['Admins']['imgs1']['name']) )
        {

        $file=$this->data['Admins']['imgs'];
        $file1=$this->data['Admins']['imgs1'];
        $ary_ext=array('jpg','jpeg','gif','png');
        $ext = substr(strtolower(strrchr($file['name'], '.')), 1);
    //  $ext1 = substr(strtolower(strrchr($file1['name'], '.')), 1); //get the extension


            if(in_array($ext,$ary_ext))
            {

               $date1=date('dmYhis');
                move_uploaded_file($file['tmp_name'], WWW_ROOT . 'img/adminimages/UploadImages/' .$date1.'_'.$file['name'] );
                move_uploaded_file($file1['tmp_name'], WWW_ROOT . 'img/adminimages/UploadImages/' .$date1.'_'.$file1['name'] );


              $n =  $this->request->data['Admins']['imgs'] = $file['name'];
               $n1 =  $this->request->data['Admins']['imgs1'] = $file1['name'];

               $date=date('d/m/Y');
               $days1=$this->data['Admins']['days'];
               $day=implode(",",$days1);

               $r_type1=$this->data['Admins']['r_type'];
               $r_types=implode(",",$r_type1);
               $my_data=array(
               'name'=>ucfirst($this->data['Admins']['name']),
               'address'=>ucfirst($this->data['Admins']['address']),
               'province'=>ucfirst($this->data['Admins']['province']),
               'region'=>ucfirst($this->data['Admins']['region']),
               'city'=>ucfirst($this->data['Admins']['city']),
               'nation'=>ucfirst($this->data['Admins']['nation']),
               'r_type'=>$r_types,
               'open_hours'=>$this->data['Admins']['hours1'].','.$this->data['Admins']['hours2'],
               'days'=>$day,
               'description'=>ucfirst($this->data['Admins']['description']),
               'logo_image'=>$date1.'_'.$n,
               'main_image'=>$date1.'_'.$n1,
               'status'=>'Active',
               'create_date'=>$date
               );

              $this->Retailer->save($my_data);
                        $this->Session->setFlash(__('Your Data Succefully Inserted.', true), 'default', array('class' => 'sukses'));    
                        $this->redirect(array('controller'=>'Admins','action'=>'uploadimage'));

            }

        }
        }
    }
    public function addname()
    {
        $this->layout='admin';

    }
    public function tabel()
    {
        $this->layout='admin';
        $this->set('Retailers' , $this->Retailer->find('all'));
    }
    public function uploadimage()
    {
        $this->layout='admin';
        $this->set('Retailers', $this->Retailer->find('all', array('order'=>array('Retailer.id DESC'),'limit'=>'1')));
        if($this->request->is('post'))
        {
            if(!empty($this->data['Admins']['imgs']['name']))
        {

        $file=$this->data['Admins']['imgs'];
        $ary_ext=array('jpg','jpeg','gif','png');
        $ext = substr(strtolower(strrchr($file['name'], '.')), 1);
    //  $ext1 = substr(strtolower(strrchr($file1['name'], '.')), 1); //get the extension


            if(in_array($ext,$ary_ext))
            {

               $date1=date('dmYhis');
                move_uploaded_file($file['tmp_name'], WWW_ROOT . 'img/adminimages/GalleryImages/' .$date1.'_'.$file['name'] );



             $date=date('d/m/Y');
              $n =  $this->request->data['Admins']['imgs'] = $file['name'];
              $gal_data=array(
              'r_id'=>$this->data['Admins']['r_id'],
              'image'=>$date1.'_'.$n,
              'title'=>ucfirst($this->data['Admins']['title']),
              'create_date'=>$date);

              $this->Gallery->save($gal_data);
              $this->Session->setFlash(__('Your Data Succefully Inserted.', true), 'default', array('class' => 'sukses'));  
                        $this->redirect($this->referer());
            }
        }
        }
    }

    public function addimage($id)
    {
        $this->layout='admin';
        $ir=$this->Retailer->findById($id);
        if($ir['Retailer']['status']=='Active')
        {
        $this->set('Gs',$this->Gallery->find('all', array('conditions'=>array('Gallery.r_id'=>$id))));
        //print_r($Gs);
        //print_r($Gallerys);
        //exit();
        if(!empty($id))
                {
                    if($this->request->is('post'))
                    {

                        if(!empty($this->data['Admins']['imgs']['name']))
        {

        $file=$this->data['Admins']['imgs'];
        $ary_ext=array('jpg','jpeg','gif','png');
        $ext = substr(strtolower(strrchr($file['name'], '.')), 1);
    //  $ext1 = substr(strtolower(strrchr($file1['name'], '.')), 1); //get the extension


            if(in_array($ext,$ary_ext))
            {

               $date1=date('dmYhis');
                move_uploaded_file($file['tmp_name'], WWW_ROOT . 'img/adminimages/GalleryImages/' .$date1.'_'.$file['name'] );



             $date=date('d/m/Y');
              $n =  $this->request->data['Admins']['imgs'] = $file['name'];
              $gal_data=array(
              'r_id'=>$id,
              'image'=>$date1.'_'.$n,
              'title'=>ucfirst($this->data['Admins']['title']),
              'create_date'=>$date);

              $this->Gallery->save($gal_data);
              $this->Session->setFlash(__('Your Data Succefully Inserted.', true), 'default', array('class' => 'sukses'));  
              $this->redirect($this->referer());
            }
        }
                    }
                }

        }
        else
        {
            $this->Session->setFlash(__('First Active this Retailer', true));
            $this->redirect($this->referer());
        }

    }
    public function uploadimage1()
    {
        if($this->request->is('post'))
        {
        $a=$this->data['Admins']['imgs'];
        print_r($a);
    }
    }
    public function updatestatus($id)
    {

            $urs=$this->Retailer->findById($id);
            if($urs['Retailer']['status']=='Active')
            {
                $this->Retailer->updateAll(array('Retailer.status' => '"De-Active"'), array('Retailer.id' => $id));
                $this->redirect(array('controller'=>'Admins', 'action'=>'tabel'));
            }
            else
            {
                $this->Retailer->updateAll(array('Retailer.status' => '"Active"'), array('Retailer.id' => $id));
                $this->redirect(array('controller'=>'Admins', 'action'=>'tabel'));
            }


        }



    public function gallery()
    {
        $this->layout='admin';
        //$this->set('Gs',$this->Gallery->find('all'));

        //$this->set('Gs',$this->Gallery->find('all', array('joins' => array(array('table' => 'retailers','alias' => 'Re','type' => 'inner','foreignKey' => true,'conditions'=> array('Re.id = Gallery.r_id'))))));
    $this->Set('Gs',$this->Gallery->find('all',array('fields'=> array('*','*'), 'joins'=> array( array('table'=>'retailers', 'type'=>'inner','conditions'=>array('Gallery.r_id=retailers.id','retailers.status'=>'Active'))))));

    //  print_r($Gs);
    //  $db =& ConnectionManager::getDataSource('default');
    //  $db->showLog();


//  exit();







    }



} ?>

这是我的控制者。

推荐答案

您必须更改安全性配置。

右:

$this->Security->config('unlockedActions', 'action_name');

错误:

$this->Security->unlockedActions = ['action_name'];

这篇关于该请求已被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆