I have a little web with two files: a index.html
that only shows a
image and a link to the second file named as change-image.php
. The
latter contain a form to upload a new image file to replace the image
showed by index.html
. It also process the form, renaming the new
image to image.jpg
and redirecting to index.html
to show it.
Looks like:
<?php
if (isset($_FILES['file'])) {
move_uploaded_file($_FILES['file']['tmp_name'], 'image.jpg');
header('Location: index.html');
exit();
}
echo <<<END
...
<form action="change-image.php" method="post" enctype="multipart/form-data">
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>
...
END;
The problem is that i get the same first image. Then I need to use the refresh button on browser to view the new image. Curiously if i repeat the action the script starts to work fine without refresh required until new browser restart (tested in firefox and chrome).