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

[eluser]Sumon[/eluser]
I have an example which might helpful for you. It re size image as well.
Code:
if(basename($_FILES['filePhoto1']['name'])!="")
    $FileName[]=Photo::FileUploadWithResize("filePhoto1");
if(basename($_FILES['filePhoto2']['name'])!="")
    $FileName[]=Photo::FileUploadWithResize("filePhoto2");
if(basename($_FILES['filePhoto3']['name'])!="")
    $FileName[]=Photo::FileUploadWithResize("filePhoto3");

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
    if($this->upload->do_upload($FileFieldName))
    {
        $FileData=$this->upload->data();    //echo "Upload hoise.";
        $MainFileName=$FileData['file_name'];
        $ThumbFileNameByCI=substr($MainFileName,0,strpos($MainFileName,".")) . "_thumb".substr($MainFileName,strpos($MainFileName,"."));
    }
    else
    {
        $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
    unset($config);
    $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);
    $this->image_lib->initialize($config);
    $this->image_lib->resize();
    unset($config);
    $this->image_lib->clear();
    return $ThumbFileNameByCI;
}


Messages In This Thread
uoploading more than one file. - by El Forum - 08-10-2008, 08:15 PM
uoploading more than one file. - by El Forum - 08-10-2008, 08:31 PM
uoploading more than one file. - by El Forum - 08-10-2008, 10:32 PM
uoploading more than one file. - by El Forum - 08-11-2008, 10:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB