我必须显示文件中提供的图像名称。说image.txt
,然后使 这些图像作为链接。在点击链接时,将会显示 显示的imagename.txt
(例如“1.jpg.txt
”)文件中的另一组图像。PHP中的图像显示
请告诉如何去做。
功能用于显示图片:
function imageDisplay($fileName)
{
$readfile = file($fileName);
// Create a loop that will read all elements of the array and print out
// each field of the tab-delimited text file
$fh = fopen($fileName, "rb") or exit("Unable to open file!");
$count =10;
for ($k=0; $k<=$count; $k++)
{
list($imageName) = fscanf($fh,"%s");
$path = "images/";
$path = trim($path.$imageName);
?>
<body bgcolor="gray">
<img src="<? echo $path; ?>" alt="<? echo $path; ?> " vspace="5" hspace="10" />
<?php
}
fclose($fh);
}
感谢, 拉维
其实我能够从文件中显示图像,但无法获取单击图像时如何获取图像名称。 – ravi 2012-04-19 03:04:27
请发布任何代码,所以我们可以诊断问题:) – F21 2012-04-19 03:05:12
更新了我的答案。 – 2012-04-19 03:13:44