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:
Nhưng tại sao khi chạy toàn báo lỗi? Giúp tôi với
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>
Bài liên quan
Parse error: parse error in c:\inetpub\wwwroot\thuchanh\imageIndex.php on line 19
Ai biết sửa giùm vợi
sai ngay $dirName = "***"; đó tốt nhất là root cùng folder đi đừng có D:\ C:\ gì cả