Save multi value in multi value field programmatically apologize every one , my code was correct , I had a mistake in content type .2 similar content type with 2 similar image field :P

but I let it and don't delete this because maybe be useful in futures

I want to save multi image in multi image field programmatically(I set number of value to 5) 

Part of my code 

        $node = new stdClass(); // Create a new node object
        $node-&gt;type = "prodcut_gift_display"; // Or page, or whatever content type you like
        $node-&gt;uid = $user-&gt;uid;
        $uri = file_build_uri($geturipath);
        $file = new stdClass;
        $file-&gt;uid = $user-&gt;uid;
        $file-&gt;filename = basename($uri);
        $file-&gt;uri = $uri;
        $file-&gt;filemime = file_get_mimetype($uri);
        $file-&gt;filesize = filesize($mainimg_url);
        $file-&gt;status = 1;
        file_save($file);
        $node-&gt;field_gift_image['und'][0] =(array) $file;
        /***************************************/
        foreach ($upimg_uri_path as $inx=&gt;$upimgtemp){
        unset($file);
        $uri = file_build_uri($upimgtemp);
        $file = new stdClass;
        $file-&gt;uid = $user-&gt;uid;
        $file-&gt;filename = basename($uri);
        $file-&gt;uri = $uri;
        $file-&gt;filemime = file_get_mimetype($uri);
//        $file-&gt;filesize = filesize($mainimg_url);
        $file-&gt;status = 1;
        file_save($file);
        $node-&gt;field_gift_image['und'][$inx+1]=(array) $file;
        }

        /***************************************/


Then I try to get drupal_json_output , it seems node and image field with 2 value is  ok but only one value saved in field.where is the problem?(I check and sure that my image field is set multi and can get 5 value )

update
Also I try 

$uri = file_build_uri($geturipath);

        $imgs_paths[]=file_create_url($uri);
        /***************************************/
        foreach ($upimg_uri_path as $inx=&gt;$upimgtemp){
        unset($file);
        $uri = file_build_uri($upimgtemp);
        $imgs_paths[]=file_create_url($uri);
        }

   foreach ($imgs_paths as $i=&gt;$img) {
    $file_info = system_retrieve_file($img, 'public://pictures/', TRUE, FILE_EXISTS_REPLACE); //storing image inside picture folder
    if ($file_info-&gt;fid) {//if fid exist then image is saved from URL.
      $node-&gt;field_gift_image['und'][$i]['fid'] = $file_info-&gt;fid; //assign image
    }
  }
        /***************************************/
        $node-&gt;field_product['und'][0]['product_id'] = $my_prodcut-&gt;product_id;
        $node-&gt;title = arg(1) . '-' . rand(1, 999999);
        $node-&gt;language = 'fa';
        $node = node_submit($node);
        node_save($node);


Also my field settings
As per my understanding you are trying to create a new article content type with multiple images. Assuming that you have the path of the images. In Drupal 7 you can use the below code


  $node = new stdClass(); // We create a new node object
  $node->type = "article"; // Or any other content type you want
  $node->title = "Article title";
  $node->language = LANGUAGE_NONE; // Or any language code if Locale module is enabled. More on this below *
  //$node->path = array('alias' => 'your node path'); // Setting a node path
  node_object_prepare($node); // Set some default values.
  $node->uid = 1; // admin id
  // Let's add standard body field
  $node->body[$node->language][0]['value'] = 'This is a body text';
  $node->body[$node->language][0]['summary'] = 'Here goes a summary';
  $node->body[$node->language][0]['format'] = 'filtered_html'; // If field has a format, you need to define it. Here we define a default filtered_html format for a body field
  // Add images
  $image_limit = 5;
  $images = array(//images to attach to node
    '0' => 'http://cf.juggle-images.com/matte/white/280x280/drupal-logo-primary.jpg',
    '1' => 'http://cdn.flaticon.com/png/256/37187.png',
    '2' => 'https://www.drupal.org/files/project-images/logo-128x128.jpg',
    '3' => 'http://guillermocerezo.com/sites/default/files/field/image/drupal-logo_0.jpg',
    '4' => 'http://drupalcrafters.org/sites/default/files/DrupalCraft-logo_0.png'
  );
  for ($i = 0; $i &#60; $image_limit; $i++) {
    $file_info = system_retrieve_file($images[$i], 'public://pictures/', TRUE, FILE_EXISTS_REPLACE); //storing image inside picture folder
    if ($file_info->fid) {//if fid exist then image is saved from URL.
      $node->field_multiple_images[LANGUAGE_NONE][$i]['fid'] = $file_info->fid; //assign image
    }
  }
  $node = node_submit($node); // Prepare node for a submit
  node_save($node); // After this call we'll get a nid
  drupal_set_message('article  saved !!!');
  watchdog('info', 'Article node created');