I am trying to take files from a folder and output them into table under categories "filename", "filetype", "filesize". The script works fine but when it outputs any other file besides basic files such as txt,php,html. When the files are jpg, .zip, etc. it will create error not being able to find the filetype or size. I am new to php so plz point out anything that i should change.
better way to show the error. The files show but it wont say the filetype or filesize correctly unless its basic file
http://likeftp.com/download.php
Code:<?php // open this directory $myDirectory = opendir("./files/photo/"); // get each entry while($entryName = readdir($myDirectory)) { $dirArray[] = $entryName; } // close directory closedir($myDirectory); // count elements in array $indexCount = count($dirArray); Print ("$indexCount files<br>\n"); // sort 'em sort($dirArray); // print 'em print("<TABLE border=1 cellpadding=5 cellspacing=0 class=whitelinks>\n"); print("<TR><TH>Filename</TH><th>Filetype</th><th>Filesize</th></TR>\n"); // loop through the array of files and print them all for($index=0; $index < $indexCount; $index++) { if (substr("$dirArray[$index]", 0, 1) != "."){ // don't list hidden files print("<TR><TD><a href=\"/files/photo/$dirArray[$index]\">$dirArray[$index]</a></td>"); print("<td>"); print(filetype($dirArray[$index])); print("</td>"); print("<td>"); print(filesize($dirArray[$index])); print("</td>"); print("</TR>\n"); } } print("</TABLE>\n"); ?>


LinkBack URL
About LinkBacks
Reply With Quote

