Hello experts,
I've consulted many times these forums and that was a lot helpfull but there's a question that i can´t seem to find and i was hoping that somebody here could have an idea:
In my site, everytime that i upload an image, the old one remains instead of the new one. The goal is to let the client upload diferent images into the server and if needed, replace some. Everything works fine, but when i replace some file, the browser still shows the old one, after the refresh "header("Location: ./where_i_want/page.php")".
Does anyone knows how to do correct this?
Here goes the code:
if (isset($cmd_carrega) && $cmd_carrega == "Carrega Imagem")
{
$ext = $_FILES['ficheiro']['name'];
$extens = strtolower(extensao($ext));
$search_array = $tipos_extensao;
$tipofile = "";
$num = count($tipos_extensao);
foreach ($tipos_extensao as $value) // Suported extension file types Ex.º "jpg","bmp","gif"
{
$tipofile = $tipofile . $value ." ";
}
if (in_array($extens, $search_array)) //Check if suported file extension
{
$uploaddir = $press_upload_area; //Upload area
$uploadfile = $uploaddir. $registo . "." .$extens;
if(file_exists("$press_upload_area$registo".".".$extensao))
{
unlink("$press_upload_area$registo".".".$extensao);
}
if (move_uploaded_file($_FILES['ficheiro']['tmp_name'], $uploadfile))
{
$ficheiro="";
$sql = "update press set extensao='$extens' where id=$registo";
$rst = mysql_query($sql);
header("Location: index.php?option=main&pag=$pag®isto=$registo"); //redirect to itself to show changes
}
else
{
echo "O ficheiro não foi carregado";
}
}
else
{
?>
<table width="100%" align="center" class="erro">
<tr>
<td>
<div align="center">
<?
echo "Não pode carregar ficheiros deste tipo. Só ficheiros dos tipos ' $tipofile ' poderão ser carregados";
?>
</div></td>
</tr>
</table>
<?
}
}