好的,我编辑了我的答案,我发现了如何在目录中找到文件,但我的问题是它不会打印图像。这是我的代码。
<?php
$file = 'testimage.png';
$dir = array(
$_SERVER['DOCUMENT_ROOT'] . "/folderA/",
$_SERVER['DOCUMENT_ROOT'] . "/folderB/"
);
foreach($dir as $d)
{
if(file_exists( $d . $file ))
{
$file = $file;
}
}
$imgPng = imageCreateFromPng($file);
header("Content-type: image/png");
imagePng($imgPng);
?>
为什么不打印图像?