• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
uoploading more than one file.

#1
[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?

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

Code:
$this->upload->do_upload('userfile');
$this->upload->do_upload('otherfile');
$this->upload->do_upload('anotherfile');

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

#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;
}

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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.