我应该创建一个动态PNG文件并通过AJAX将其上传到服务器,并返回该文件的URL。
然而,图像总是一样的。
JS代码是:
$.ajax({
url: "ajax/genPOCode.php",
data: "comp=" + competicio,
type: "GET",
success: function ( result )
{
window.prompt ( result );
}
});
AJAX文件的代码是:
$time = time();
clearstatcache();
$nas = file_get_contents ( "http://www.example.com/playoffsimg2.php?upload=" . $time . "&leagueid=" . $_GET['comp'] . "&day=FINAL" );
echo utf8_encode ( "http://www.example.com/images/brackets/" . $time . "-" . $_GET['comp'] . ".png" );
playoffsimg2.php文件的PHP代码是:
Line 1: header("Cache-Control: no-cache, must-revalidate");
Line 2: header ( "Content-Type: image/png" );
Line 466: imagepng ( $image, "images/brackets/" . $_GET['upload'] . "-" . $_GET['leagueid'] . ".png" );
Line 467: imagedestroy ( $image );
我认为这是与缓存相关的问题,因为当我从浏览器调用文件http://www.example.com/playoffsimg2.php时,它可以正常工作。