【发布时间】:2012-03-27 17:48:54
【问题描述】:
我有一个 php 页面,其中包含一些用于上传图像的表单。每个表单上传一张图片。上传的图片会替换页面中尚未加载的图片。
这是一个sn-p:
<?php
// NO CACHING CODE
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
// FORM SUBMIT CODE
if (isset($_POST['submit_img1'])) {
// used for some photo manipulation and checks
require_once('WideImage/WideImage.php');
//... some code ...
unlink("path/" . $img1);
$img_name = "path/" . $img1;
$wideImage->saveToFile($img_name, 80);
// ... some code ...
}
// PRINT IMAGE IN THE PAGE
echo '<p><img src="path/' . $img1 . '" width="100" height="100" class="prof_img" /></p>';
?>
//FORM FOR CHANGE THE IMAGE
<form id="form_img1" name="form_img1" method="post" onSubmit="return checkFormImg1()"
action="" enctype="multipart/form-data">
<input class="prof_input" type="file" name="img1" id="img1" />
<input name="submit_img1" type="submit" class="prof_submit" value="Inserisci Immagine 1"
/>
</form>
问题是在重新加载时(按下提交按钮后)旧图像会显示。但新图片已正确上传,替换旧图片。
对不起,我的英语不好。
【问题讨论】: