我必須顯示文件中提供的圖像名稱。說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