Welcome Guest, Not a member yet? Register   Sign In
files wont upload
#1

[eluser]Uplift[/eluser]
Cant seem to get files to upload. where am i going wrong?

Code:
if (!$this->input->post('userfile')) { //check if userfile is set
    
          $post['image'] = 'none'; // if not then set 'none
                
} else { // is set
                
          $this->events_model->do_upload(); // call model to start uploading
          $post['image'] = $image_data['file_name']; //grab filename
                    
}

//events mode:

    function do_upload() {
        
        $config = array( //set config
            'allowed_types' => 'jpg|jpeg|gif|png',
            'upload_path' => '/home/ubuzznet/public_html/ubuzz/content/uploaded_flyers/', //ive also tried ./content/uploaded_flyers/
            'max_size' => 3500
        );
        
        $this->load->library('upload', $config);
        $this->upload->do_upload(); //start upload from 'userfile' field
        $image_data = $this->upload->data(); // set image data
        
    }

// upload field;

echo form_upload(array('name' => 'userfile', 'class' => 'userfile', 'id' => 'userfile'));
#2

[eluser]Jônatan fróes[/eluser]
What does
Code:
$this->upload->display_errors()
returns?
#3

[eluser]Uplift[/eluser]
[quote author="Jônatan fróes" date="1313440525"]What does
Code:
$this->upload->display_errors()
returns?[/quote]

I dont get any errors Sad

it's as if it's not setting because it fills the db entry with 'none' which is what it should do if there is no image.
#4

[eluser]Twisted1919[/eluser]
$this->input->post('userfile') will always be empty because the field is in $_FILES not in $_POST.
Also, your form needs to have enctype="multipart/form-data" in order for the upload to work.
#5

[eluser]Uplift[/eluser]
[quote author="Twisted1919" date="1313443568"]$this->input->post('userfile') will always be empty because the field is in $_FILES not in $_POST.
Also, your form needs to have enctype="multipart/form-data" in order for the upload to work.[/quote]

Ah i see, got it working now thanks for clearing that up.




Theme © iAndrew 2016 - Forum software by © MyBB