title: Retrieve images from different PCs
body: <p>I'm developing a website (HTML, CSS, PHP, JavaScript) which needs to have access to different PCs and getting images. Then I want to display those images to any user uses my program.</p>
  
  <p>For example I want to open the folderA that is on pcA from my PC and get all the images in 
  that folder and display them in my site. Is this possible?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>$dir1 = "pictures/";
  $dir2 = "pictures2/";
  $dir3 = "pictures3/";
  
   $basedir = array(
      'basedir1' =&gt; $dir1 ,
      'basedir2' =&gt; $dir2 ,
      'basedir3' =&gt; $dir3 
     );
  
      function readGPSinfoEXIF($image_full_name)
      {
      if (file_exists($image_full_name) )
       {
         $exif=exif_read_data($image_full_name, 0, true);
         if ( !empty($exif['GPS']['GPSLatitude']) )
         {
  
           if(!$exif || $exif['GPS']['GPSLatitude'] == '') 
            {
             return false; 
            } 
  
            else 
             {
              $lat_ref = $exif['GPS']['GPSLatitudeRef']; 
              $lat = $exif['GPS']['GPSLatitude'];
              list($num, $dec) = explode('/', $lat[0]);
              $lat_s = $num / $dec;
              list($num, $dec) = explode('/', $lat[1]);
              $lat_m = $num / $dec;
              list($num, $dec) = explode('/', $lat[2]);
              $lat_v = $num / $dec;
  
              $lon_ref = $exif['GPS']['GPSLongitudeRef'];
              $lon = $exif['GPS']['GPSLongitude'];
              list($num, $dec) = explode('/', $lon[0]);
              $lon_s = $num / $dec;
              list($num, $dec) = explode('/', $lon[1]);
              $lon_m = $num / $dec;
              list($num, $dec) = explode('/', $lon[2]);
              $lon_v = $num / $dec;
  
              $gps_int = array($lat_s + $lat_m / 60.0 + $lat_v / 3600.0, $lon_s + $lon_m / 60.0 + $lon_v / 3600.0);
  
              return $gps_int;
             }//end of else
          }//end of if checking if GPS value is not empty
        }//check if file exists
      }//end of function
  
               function dirImages($dir) 
                  {
                   $d = dir($dir);
                   while (false!== ($file = $d-&gt;read())) 
                      {
                       $extension = substr($file, strrpos($file, '.')); 
                       if($extension == ".jpg" || $extension == ".jpeg" || $extension == ".gif" |$extension == ".png") 
                       $images[$file] = $file; 
                      }
                      $d-&gt;close();         
                      return $images; 
                  }
  
  $COUNTER_IMAGE = 0;   
  
  foreach ($basedir as $dir) // array of dirs path p.x pictures/
     {
          $array = dirImages($dir);
          $counter =count($array);
  
          $sql_ip = "SELECT dir FROM users WHERE dir = '".$dir."' ";
          $result_ip = mysql_query($sql_ip);
          $row_ip = mysql_fetch_assoc($result_ip);
  
          if(empty($row_ip['dir']) )
             {              
               //inserting user details
               $insert_user_details= @mysql_query("
                  INSERT INTO users 
                  VALUES(
                  '', 
                  '$localIP', 
                  '', 
                  '".$dir."',
                  '".$data['latitude']."', 
                  '".$data['longitude']."',
                  '".$data['ipAddress']."',
                  '".$data['countryName']."',
                  '".$data['cityName']."'
                  ) ");
              }
  
              $sql_user = "SELECT user_id FROM users 
              WHERE  dir ='".$dir."'  ";
              $result_user = mysql_query($sql_user);
              $row_user = mysql_fetch_assoc($result_user);
  
              foreach ($array as $key) 
              {
                  $image_full_name = $dir."/".$key; 
                  $results = readGPSinfoEXIF($image_full_name);
                  $latitude = $results[0];
                  $longitude = $results[1];
  
                  $sql = "SELECT * FROM monument_info 
                  WHERE monument_longitude='".$longitude."' AND monument_latitude ='".$latitude."'  ";
                  $result = mysql_query($sql);
                  $row = mysql_fetch_assoc($result);
  
                                      if( ($longitude != $row['monument_longitude'])
                                      &amp;&amp; ($latitude   != $row['monument_latitude']) 
                                      &amp;&amp; empty($row['monument_longitude'])
                                      &amp;&amp; empty($row['monument_latitude']) 
                                      )
  
                                      {
                                          //$COUNTER_IMAGE = $COUNTER_IMAGE + 1;
                                          $insert_monument_details= @mysql_query("
                                          INSERT INTO monument_info 
                                          VALUES(
                                          '".$row_user['user_id']."', 
                                          '$longitude', 
                                          '$latitude',
                                          '', 
                                          '',
                                          '".$image_full_name."'
                                          ) ");
  
                                          if (file_exists($image_full_name) )//This if statement hides a bug
                                              {
                                                echo "&lt;img  src='".$image_full_name."'   widht=350 height='300' /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;";
                                              }
                                      }
  
                                  else
                                  {
                                      if (file_exists($image_full_name) )//This if statement hides a bug
                                      {
                                          if( !empty($row['monument_longitude']) &amp;&amp; !empty($row['monument_latitude']) )
                                          {
                                            echo "&lt;img  src='".$image_full_name."'   widht=350 height='300' /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;";
                                          }
                                      }
                                  }
              }//end of foreach of printing images in folder
      }
  </code></pre>