Welcome Guest, Not a member yet? Register   Sign In
Upload Problem!

hello, Here is my program code in controller:

public function create_user(){
if($this->form_validation->run()== FALSE) {        

public function upload1(){
/*----- Upload -----*/
if ( isset($_FILES['userfile']['name']) AND strlen($_FILES['userfile']['name']) > 3 ){
$this->gallery_path = realpath(APPPATH.'../uploads');
$config['upload_path'] = $this->gallery_path;
$config['allowed_types']    = 'gif|jpg|jpeg|png';
$config['max_size']         = '2000';    
$config['file_name']        = $this->input->post('ref');


if (! $this->upload->do_upload()){
  //echo $this->upload->display_errors();
   $this->form_validation->set_message('upload1','Something Wrong Image Type');
   return FALSE;
$image_data = $this->upload->data();
  /*----- Image Config -----*/
  $config['source_image']     = $image_data['full_path'];
  $config['new_image']        = $this->gallery_path.'/thumbs';
  $config['maintain_ratio']   = TRUE;  
  $config['width']            = 150;
  $config['height']           = 100;

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

I created form, in which i'm using image upload function. But when i post the form without filling the required field, Validation error comes but image uploaded in the folder. that shouldn't be happened. Any Idea?


[eluser]Hank the Punk[/eluser]
Are you loading http://yoursite.com/controller/upload1 anywhere ??
As upload1() is public that url should work. If this is not intended, set the function to private by adding an underscore to the name.
public function _upload1() {
(The same happens to 'create_user()')

Theme © iAndrew 2016 - Forum software by © MyBB