farkewie Posted November 8, 2007 Share Posted November 8, 2007 Hello i have some working code here that creats a list of links in the noted directory, but i would like it to remove file extenions. they are all word docs. also is there a way to force it to open in the browser? all computers will be running latest IE6 and maybe IE 7 in the future. <?php $intCounter = 1; $ref = $_SERVER['PHP_SELF']; if ($handle = opendir('./cheat_sheets')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo "<div id=\"left-panel\"><a href=\"$ref?album=$file\">$file</a></div>"; } } closedir($handle); } ?> Quote Link to comment Share on other sites More sharing options...
Orio Posted November 8, 2007 Share Posted November 8, 2007 <?php $intCounter = 1; $ref = $_SERVER['PHP_SELF']; if ($handle = opendir('./cheat_sheets')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $file = substr($file, 0, -(strlen($file)-(strrpos($file, ".")))); echo "<div id=\"left-panel\"><a href=\"$ref?album=$file\">$file</a></div>"; } } closedir($handle); } ?> As for forcing the browser to open the doc file instead of prompting to download it, you can send the following header: header("Content-type: application/msword"); And then echo the contents of the file (see readfile()). Orio. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.