Fabriciojf.com Wiki
  • FAQ
    • APIs
      • FAQs Favoritos

        Qual é a sua dúvida?

        •  Página inicial do FAQ
        • Cake PHP
        • Upload de Arquivos no Cakephp - File Upload

        Upload de Arquivos no Cakephp - File Upload

        View

          echo $this--->Form->create(false, array(
              'type' => 'file', // <---- Important
              'url' => array(
                  'admin' => true,
                  'controller' => 'tab_trees',
                  'action' => 'upload_json', $this->request->data['TabTree']['id']
              )
          ));
        
          echo $this->Form->input('file', array(
              'class' => 'form-control',
              'label' => false,
              'type' => 'file',  // <---- Important
          )); 
        
          echo $this->Form->end(array(
              'label' => __('Upload File'),
              'class' => 'btn btn-sm btn-primary'
          ));
        

        Controller

        public function admin_upload_json($id = null)
        {
            debug($this->request->data);
            die;
        
            $this->TabTree->id = $id;
            if (!$this->TabTree->exists) {
                throw new NotFoundException(sprintf(__('Invalid %s'), __('tab tree')));
            }
        }
        
         Página inicial do FAQ
        • FAQ
          • APIs
            • FAQs Favoritos

              © Copyright 2025 Fabriciojf.com  Criado por FábioCostaMKT   Pastes   Administração