PHP-路径无法访问自己的目录

PHP-路径无法访问自己的目录,php,xampp,Php,Xampp,在测试目录localhost/test5/中,此代码运行良好 <?php header('Content-type: image/jpeg'); $font=realpath('../test5/fonts/arial.ttf'); $font2=realpath('../test5/fonts/sign.otf'); $image=imagecreatefromjpeg("format4.jpg"); $color=imagecolorallocate($imag

在测试目录localhost/test5/中,此代码运行良好

<?php
header('Content-type: image/jpeg');

$font=realpath('../test5/fonts/arial.ttf');
$font2=realpath('../test5/fonts/sign.otf');

$image=imagecreatefromjpeg("format4.jpg");
$color=imagecolorallocate($image, 51, 51, 102);
 

$user="john";
imagettftext($image, 30, 0, 670, 550, $color,$font, $name);
imagejpeg($image,"../psm2/images/certificate/$name.jpg");
imagejpeg($image);
imagedestroy($image);
?>
这条线没有按我的意愿工作。它看起来像是
test5
localhost目录,能够访问我的
psm2
目录并生成映像,但是
psm2
即使在自己的目录中也无法执行同样的操作。如果我将整个通道
imagejpeg
更改为comment,则一切正常,但我无法生成图像

p/s:这个问题也发生在

$font=realpath('../test5/fonts/arial.ttf');
$font2=realpath('../test5/fonts/sign.otf');
test5
能够访问
。/test5/font
。/psm2/font
,但让我们关注一下关键问题,如果我在
psm2
目录中实现代码,我将无法生成图像

是否有一种方法可以检查路径或清除缓存路径。谢谢你

$font=realpath('../test5/fonts/arial.ttf');
$font2=realpath('../test5/fonts/sign.otf');