title: php rename swap file names doesnt reload image
body: <p>i am working on a website that has a set of images and 1st image is like an avatar.. when i want to change the avatar (1st picture) what i do is i swap the 1st image name with the new image that i want to use as avatar.
  I do this on an ajax function so i dont need to refresh the page after i do that.</p>
  
  <pre><code>rename("C:/wamp/www/invest/Coded/oferte/" . $offer_id . "/" . $pic_name, "C:/wamp/www/invest/Coded/oferte/" . $offer_id . "/" . $temp_name);
  rename("C:/wamp/www/invest/Coded/oferte/" . $offer_id . "/" . $avafile, "C:/wamp/www/invest/Coded/oferte/" . $offer_id . "/" . $pic_name);
  rename("C:/wamp/www/invest/Coded/oferte/" . $offer_id . "/" . $temp_name, "C:/wamp/www/invest/Coded/oferte/" . $offer_id . "/" . $avafile);
  </code></pre>
  
  <p>My problem is after i do that, i delete the images from the div and i add them again in the new order, but i think the browser saves the images somewhere and dont reload them and they appear in same order. Only after i refresh the page, they appear in the right order.
  Is there like a solution to make the browser upload the images again ?</p>
  
  <p>Thank you in advance, Daniel!</p>
  
  <p>EDIT: This is the ajax function:</p>
  
  <pre><code>function avaPic(offer_id, pic_name, onFinish) {
      var request;
      if(window.XMLHttpRequest)
          request = new XMLHttpRequest();
       else
          request = new ActiveXObject("Microsoft.XMLHTTP");
  
      request.onreadystatechange = function() {
          if (request.readyState == 4 &amp;&amp; request.status == 200) {
              onFinish();
          }
      }
  
      request.open("GET", "php/script.php?action=avaPic&amp;offer_id=" + offer_id + "&amp;pic_name=" + pic_name, true);
      request.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
      request.send();
  }
  </code></pre>
  
  <p>and this is the php:</p>
  
  <pre><code>if($action == "avaPic") {
          $offer_id = $_GET["offer_id"];
          $pic_name = $_GET["pic_name"];
          $filearray = getDirectoryList("C:/wamp/www/invest/Coded/oferte/" . $offer_id . "/");
          $avafile = $filearray[0];
          $temp_name = "temp.jpg";
  
          rename("C:/wamp/www/invest/Coded/oferte/" . $offer_id . "/" . $pic_name, "C:/wamp/www/invest/Coded/oferte/" . $offer_id . "/" . $temp_name);
          rename("C:/wamp/www/invest/Coded/oferte/" . $offer_id . "/" . $avafile, "C:/wamp/www/invest/Coded/oferte/" . $offer_id . "/" . $pic_name);
          rename("C:/wamp/www/invest/Coded/oferte/" . $offer_id . "/" . $temp_name, "C:/wamp/www/invest/Coded/oferte/" . $offer_id . "/" . $avafile);
      }
  </code></pre>
  
  <p>on the onFinish function, i refresh the div wih the images in hope they reorder again in the new order, but they appear same as they were before, untill i refresh the page</p>
  
  <p>I found it, how to force the browser reload the images. </p>
  
  <pre><code>&lt;div&gt;
         &lt;img src="img1.jpg" /&gt;
         &lt;img src="img2.jpg" /&gt;
         &lt;img src="img3.jpg" /&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>instead this, i have to generate a html code with a time parameter in order to make browser reload the images. like this <code>&lt;img src='"img1.jpg?" + d.getTime()' /&gt;</code></p>