我正在使用 Google Chart API 将图表转换为图像,然后将其下载到我的下载文件夹中。现在下载后我想重命名图像文件并将其移动到我rename()
在 PHP 中使用函数的其他目录。
现在我面临的问题是rename()
PHP 中的函数在我可以执行下载图像函数(在 javascript 中)之前执行,因此它给了我错误显示“找不到指定的文件”。
我尝试过使用 PHP 延迟函数usleep()
和 javascript 函数setTimeOut()
,也尝试过“浪费时间”的循环。但没有任何成功。有人可以建议我一些我可以实现的东西。
This is my code:
/*Firstly there is the google line chart code */
In body I have:
<script type="text/javascript">
onload = function download_this(){
grChartImg.DownloadImage('chart_div');
}
</script>
//PHP
<?
$changefrom = "C:/somelocation/Downloads/download" ;
$changeto = __DIR__.'\mygraph';
rename($changefrom, $changeto.'.png');
?>
这是 grchartimg 库,用于转换和下载图形图像。我想要覆盖保护,这就是我使用重命名的原因。因为重命名后我想将此图像嵌入到 PDF 文件中。