Welcome Guest, Not a member yet? Register   Sign In
uoploading more than one file.

[eluser]PHP Programmer[/eluser]
I have uploaded one file but I have other options to upload other files also on the same page. I have to upload them (two files more)separately without making an array. If I give the name other than userfile then no more files get uoplaoded. How can I do get success?

[eluser]Colin Williams[/eluser]
Run the upload process for each field:


Sounds like you added fields on the front end and did nothing on the back-end to accommodate. It isn't magic ya know! Smile

I have an example which might helpful for you. It re size image as well.

function FileUploadWithResize($FileFieldName)
    $config['upload_path'] = './gallery/image_gallery/tmp_photos/';    //Change it by your image folder name
    $config['allowed_types'] = 'gif|jpg|jpeg|png';
    $config['max_size']    = '10000';
    $config['max_width']  = '4000';
    $config['overwrite']  = FALSE;
    $config['max_height']  = '4000';
    $this->load->library('upload', $config);
    // Upload Main Picture into tmp_photos
        $FileData=$this->upload->data();    //echo "Upload hoise.";
        $ThumbFileNameByCI=substr($MainFileName,0,strpos($MainFileName,".")) . "_thumb".substr($MainFileName,strpos($MainFileName,"."));
        $error = array('error' => $this->upload->display_errors());    //echo $error['error'];
        $this->session->set_userdata("UploadErrors" , $this->session->userdata("UploadErrors")."<br>".$error['error']);
        return FALSE;
    // Resize $MainFileName to BigPicture (600X450) into original_photo
    $config['image_library'] = 'GD2';
    $config['source_image'] = './gallery/image_gallery/tmp_photos/'.$MainFileName;    //Change it by your image folder name
    //$config ['quality'] = '80%';
    $config['master_dim'] = 'auto';
    $config['create_thumb'] = TRUE;
    $config['maintain_ratio'] = TRUE;
    $config['width'] = 600;
    $config['height'] = 450;
    $config['new_image'] = './gallery/image_gallery/photo_original/'.$MainFileName;
    $this->load->library('image_lib', $config);
    return $ThumbFileNameByCI;

[eluser]PHP Programmer[/eluser]
thanks for your replies...it worked Smile

Theme © iAndrew 2016 - Forum software by © MyBB