我有第一个 PHP 脚本,它允许我在远程服务器上显示图像。这个有效,我想设定一个条件,以便当它在 $file 变量中找不到图像时,它会在 $newfile 变量中显示图像。
但我收到错误消息“警告:file_get_contents():C:\wamp64\www 中的文件名不能为空...”
我的错误在哪里?
<!-- Old Script -->
<?php
$file = '//Alcyons/it/PhotoShoot/Photos_Outil/A1111_0070_1.jpg';
$type = pathinfo($file, PATHINFO_EXTENSION);
?>
</td>
<td valign=top align=center>
<img src="<?php echo "data:image/$type;base64,",
base64_encode(file_get_contents($file)) ?>" border=0 width="180"></a>
</td>
<td width=10></td>
<!-- New Script -->
<?php
$file = '//Alcyons/it/PhotoShoot/retail/Photos/SS20,FW1920/A1127G_00_1.jpg';
$newfile = '//Alcyons/it/PhotoShoot/retail/Photos/SS20,FW1920/A1119_4023_1.jpg';
$type = pathinfo($file, PATHINFO_EXTENSION);
?>
</td>
<td valign=top align=center>
<img src="<?php
if ($file = NULL)
{
echo "data:image/$type;base64,", base64_encode(file_get_contents($newfile));
}
else
{
echo "data:image/$type;base64,", base64_encode(file_get_contents($file));
}
?>" border=0 width="180"></a>
</td>
<td width=10></td>
慕仙森