CodeIgniter Forums

Full Version: Upload Problem!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

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?


El Forum

[eluser]Hank the Punk[/eluser]
Are you loading 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()')