09/10/2018, 18:22

Sao đoạn code PHP đọc file ko chạy được

Tôi có chương trình đọc file ảnh trong 1 thư mục và hiển thị dưới dạng thumnail viết bằng PHP như sau:
Code:
<html>
<head>
<title>imageIndex</title>
</head>
<body>

<?

// image index
// generates an index file containing all images in a particular directory
//point to whatever directory you wish to index.
//index will be written to this directory as imageIndex.html
$dirName = "C:Inetpubwwwroot	huchanhcards";
$dp = opendir($dirName);

//add all files in directory to $theFiles array
$theFiles = array();
while ($currentFile = readdir($dp)) {
	if ((eregi("gif$",$currentFile)) || (eregi("jpg$",$currentFile))) {
		$theFiles[] .= $currentFile;
	}
} // end while

closedir($dp);
//extract gif and jpg images
foreach ($theFiles as $currentFile){
$output .= <<<HERE
<a href = $currentFile>
<img src = "$currentFile"
	height = 50
	width = 50>
</a>
HERE;
} // end foreach
//save the index to the local file system
$fp = fopen("imageIndex.html", "w");
fputs ($fp, $output);
fclose($fp);
//readFile("imageIndex.html");
print "<a href = $dirName/imageIndex.html>image index</a>
";

?>

</body>
</html>
Nhưng tại sao khi chạy toàn báo lỗi? Giúp tôi với
vnpenguin viết 20:36 ngày 09/10/2018
Cụ thể là lỗi gì ? Bạn nói có lỗi mà sao không post lên đây luôn ?
huhuhuhu viết 20:38 ngày 09/10/2018
Lỗi thông báo là:
Parse error: parse error in c:\inetpub\wwwroot\thuchanh\imageIndex.php on line 19
Ai biết sửa giùm vợi
satthuhuydiet viết 20:38 ngày 09/10/2018
Ạc Dir [Đường dẫn] sai thì error chứ gì mà hỏi
sai ngay $dirName = "***"; đó tốt nhất là root cùng folder đi đừng có D:\ C:\ gì cả
huhuhuhu viết 20:36 ngày 09/10/2018
Toi sua duoc roi, hoa ra la do loi duong dan. Thank iu nhe.
satthuhuydiet viết 20:23 ngày 09/10/2018
Ok good rồi hử hê hê thanks for share scripts
Bài liên quan
0