I am using multiple file upload module in CodeIgniter; the script is totally successful, just a simple error, might be a silly one is happening.

First I would like to share a concept. In a website people are registering using their email id now when people are registering using a email id, a folder for that guy gets created in the server by the name of the email id. Say I register in the site by email id `saswat.saz.routroy@gmail.com`, then when i log in the session starts as `$_SESSION['logged_user']="saswat.saz.routroy@gmail.com"`.

Again when I am registering, a folder gets created in the server with the name `saswat.saz.routroy@gmail.com`. Now I want to upload images into the folder "saswat.saz.routroy@gmail.com".

I am using the script

```
foreach($_FILES['photo']['name'] as $key=>$val)
          {
             if($_FILES['photo']['name'][$key]=="")
                {
                  //return "Successfully Added";
                }
             else if($_FILES['photo']['name'][$key]!='' && ($_FILES['photo']['type'][$key]='jpeg'
                     || $_FILES['photo']['type'][$key]='jpg' || $_FILES['photo']['type'][$key]='JPG'
                     || $_FILES['photo']['type'][$key]='JPEG') )
                {

                      $f_name=$_FILES['photo']['name'][$key];
                      $s_name=array();
                      $s_name=explode('.',$f_name);
                      $name=$s_name[0];
                      $name="(".$order_date.")".$name;
                      $slug= $name;
                      $slug = trim($slug," ");
                      $slug = trim($slug,"-");
                      $slug=str_replace(" ", "-", $slug);
                      $slug=str_replace("/", "-", $slug);
                      $slug=str_replace("|", "-", $slug);
                      $slug=str_replace("!", "-", $slug);
                      $slug=str_replace("+", "-", $slug);
                      $slug=str_replace("*", "-", $slug);

                      $data = array(
                             'photo_id' => NULL,
                             'order_id' => $last_order_id,
                             'user_id' => $user_id,
                             'photo_name'=>$name,
                             'photo_folder'=>$_SESSION['logged_user'],
                             'order_date'=>$order_date
                             );
                      if($this->db->insert('photo_table', $data))
                        {
                             $last_id=mysql_insert_id();
                             $slug= $last_id."-".$slug;
                             $this->db->query("UPDATE photo_table
                             SET photo_slug='$slug' WHERE photo_id='$last_id'");
                        }
                      $image= $_SESSION['logged_user'].'/'.md5(uniqid(rand())).$_FILES['photo']['name'][$key];
                      $img="./".$image;
                      move_uploaded_file($_FILES['photo']['tmp_name'][$key],$img);
                      $fullpath=$image;
                      $this->db->query("UPDATE photo_table
                                SET photo_path='$fullpath' WHERE photo_id='$last_id'");

                }

          }
          return "Successfully Uploaded";

```

Where `$_SESSION['logged_user']="saswat.saz.routroy@gmail.com"`. Now, this script is not giving any error, but still files arent getting uploaded, although the database is getting updated as it should be.

But if I use the script:

```
$image= 'photo_folder/'.md5(uniqid(rand())).$_FILES['photo']['name'][$key];

```

instead of

```
$image= $_SESSION['logged_user'].'/'.md5(uniqid(rand())).$_FILES['photo']['name'][$key];

```

then files are getting uploaded perfectly. That means its just about the folder name that's causing error, but I need to upload file in such method.