PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, January 30, 2022

[FIXED] Upload rules don't overwrite on IC

 January 30, 2022     codeigniter, php     No comments   

Issue

I made a formulary with 2 diferents uploads and diferents rules (one for image and one for archive), the image upload works, but when goes to archive the rules dont overwrite (continues with the rules of the image).

I tried to load the library on construct, dont work.

The function of Image Upload:

    $configImagem['upload_path']   = './files/noticias/imagens';
    $configImagem['allowed_types'] = 'gif|jpg|jpeg|png';
    $configImagem['file_name']     = 'Img_noticia_'.date('y-m-d_h-i-s');
    $this->load->library('upload',$configImagem);

    $check = $this->upload->do_upload('imagem');

    if($check == TRUE){ 
        return TRUE;
    } else if($check == FALSE){
        $this->session->set_flashdata('erro', '<strong>Erro:</strong>'.$this->upload->display_errors());
        return FALSE;
    }
}

public function upArquivo(){
    $configArq['upload_path']   = './files/noticias/arquivos';
    $configImagem['allowed_types'] = 'pdf|txt|doc';
    $configArq['file_name']     = 'Arq_noticia_'.date('y-m-d_h-i-s');
    $this->load->library('upload',$configArq);
    $this->upload->initialize($configArq);

    $checkArq = $this->upload->do_upload('arquivo');

    if($checkArq == TRUE){ 
        return TRUE;
    } else if($checkArq == FALSE){
        $this->session->set_flashdata('erro', '<strong>Erro:</strong>'.$this->upload->display_errors());
        return FALSE;
    }
}

Solution

The variable $configImagem has to be $configArq.



Answered By - Marcos Neto
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing