Roadirsh
Roadirsh

Reputation: 572

File_put_contents not overwriting on img /Firefox

So, i have some img who are store in a database, i would like to show them once at a time in a so i do this:

$sql = "SELECT IMG from pdescriptif_s where KEY = '".$KEY."' "; 
$q = $base->prepare($sql);
$q->execute();

$q->bindColumn(1, $cover, PDO::PARAM_LOB);

while($q->fetch())
{
    return $cover;
}

(it's a function and then, i call it like that:)

  <?php file_put_contents("text.jpg",getimg($key)); ?>
    <img src='text.jpg' id='blob' alt=""> <br/>

this little code is called on change on a select tag like that:

$('#Theselect').change(function(){
$('#thedivoftheimg').load(getContentimg('img-signature'));
});

and getContentimg is:

function getContentimg(x){
$.ajax({
type: 'GET', 
url:"imgsign.php",
data:"modele="+$('#modele').val()+"&soc=<?php echo $_SESSION['SOC'] ?>",
success  : function(data){  
 obj=document.getElementById(x);
 obj.innerHTML = data;
 tinymce.init({selector:'textarea',
 menubar: false});
 }       
})
}

So all this works fine in Opera and Chrome, when i change an option in the select, an other img is write on text.jpg but in Firefox it's okay once and then it's never overwrite, i need to do F5 and actualize to make it work again. Why that ?

Upvotes: 1

Views: 137

Answers (1)

That is because the image is getting cached.

Add a uniqid() to the image to force reload it. It would be something similar to this..

<img src='text.jpg?id=<?php echo uniqid();?>' id='blob' alt=""> <br/>

Upvotes: 1

Related Questions