Duepilind Posted April 5, 2008 Share Posted April 5, 2008 Ok, below is my script. The function of the script is to go into a folder (docbank2 in this case) and list the files + information and link to the files. Just a simple little thing I've put together after my second day of PHP-programming - Yay! However, for some reason my fclose function won't work. This is probably a simple problem, but I would be greatful if anyone could help me. Thank you in advance for your response! Cheers! Duepilind <table border="1" cellspacing="2" cellpadding="2"> <tr> <td><b>Nr</b></td><td><b>Filename</b></td><td><b>Filesize</b></td><td><b>Type</b></td><td><b>Last accessed</b></td><td><b>Last modified</b></td></tr> <?php function tstamp_to_date($tstamp) { return date("m-d-y g:i:sa", $tstamp); } function findexts ($file) { $file = strtolower($file) ; $exts = split("[/\\.]", $file) ; $n = count($exts)-1; $exts = $exts[$n]; return $exts; } $sub = ($_GET['dir']); $path = 'docbank2/'; $path = $path . "$sub"; $dh = opendir($path); $i=1; while (($file = readdir($dh)) !== false) { if($file != "." && $file != "..") { if (substr($file, -4, -3) =="."){ echo "<tr><td>$i.</td><td><a href=\"$path$file\" target=\"_blank\">".basename($file)."</a></td><td>"; $ed = $path . $file; $fh = fopen($ed, "r"); $fileinfo = fstat($fh); echo round(($fileinfo["size"]/1024), 2)." kb</td><td>"; echo findexts($file)."</td><td>".tstamp_to_date($fileinfo["atime"])."</td><td>".tstamp_to_date($fileinfo["mtime"])."</td></tr>"; /* This is where I need help! =) */ fclose($ed); }else{ echo "<tr><td>$i.</td><td>$file</td><td> </td><td>Folder</td><td> </td><td> </td></tr>"; } $i++; } } closedir($dh); ?> </table> Link to comment https://forums.phpfreaks.com/topic/99650-fclose-issue-probably-simple/ Share on other sites More sharing options...
benjaminbeazy Posted April 5, 2008 Share Posted April 5, 2008 fclose($fh); for future reference, you should mention what happens. ie error msg, etc. Link to comment https://forums.phpfreaks.com/topic/99650-fclose-issue-probably-simple/#findComment-509768 Share on other sites More sharing options...
Duepilind Posted April 5, 2008 Author Share Posted April 5, 2008 I will and thank you! Link to comment https://forums.phpfreaks.com/topic/99650-fclose-issue-probably-simple/#findComment-509787 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.