xtreme_dry Posted March 2, 2007 Share Posted March 2, 2007 hey ive got a php file to show the links to all the files in a particular folder but its not working anymore can any one help heres the code: this is the include function in my html page <?php include("downloadfile.php") ?> and heres downloadfile.php <html> <head> <style> body { background-color:#CCCCCC; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; } ul { list-style:none; } ul li a { width:100px; height:50px; background-color:#FFFFFF; border:#000000 1px solid; text-decoration:none; color:#000000; padding:5px; } ul li a:hover { background-color:#CCCCCC } </style> <body> <?php $path = "./uploads"; $dir_handle = @opendir($path) or die("Unable to open $path"); while ($file = readdir($dir_handle)) { if($file == "." || $file == ".." || $file == "index.php" ) continue; echo "<ul><li><a href=uploads/$file>$file</a></li></ul>"; } // Close closedir($dir_handle); ?> </body></head></html> Quote Link to comment Share on other sites More sharing options...
itsmeArry Posted March 2, 2007 Share Posted March 2, 2007 use it like this if($file != "." && $file != ".." && $file != "index.php" ) echo "<ul><li><a href=uploads/$file>$file</a></li></ul>"; [/c0de] Quote Link to comment Share on other sites More sharing options...
xtreme_dry Posted March 2, 2007 Author Share Posted March 2, 2007 nope still wont display the files Quote Link to comment Share on other sites More sharing options...
xtreme_dry Posted March 2, 2007 Author Share Posted March 2, 2007 is there anything wrong with the include function? because i can open the page fine if i type in the url and it all works it just wont display in the page Quote Link to comment Share on other sites More sharing options...
itsmeArry Posted March 2, 2007 Share Posted March 2, 2007 try changing $path = "./uploads"; to $path = "uploads"; Quote Link to comment Share on other sites More sharing options...
itsmeArry Posted March 2, 2007 Share Posted March 2, 2007 you are missing a ; include("downloadfile.php") use this include("downloadfile.php"); Quote Link to comment Share on other sites More sharing options...
xtreme_dry Posted March 2, 2007 Author Share Posted March 2, 2007 nope still don't wanna work Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 2, 2007 Share Posted March 2, 2007 windows setting $path = "uploads/"; Quote Link to comment Share on other sites More sharing options...
xtreme_dry Posted March 2, 2007 Author Share Posted March 2, 2007 nopes till won't work Quote Link to comment Share on other sites More sharing options...
Snooble Posted March 2, 2007 Share Posted March 2, 2007 lol <?php $path = "./uploads"; $dir_handle = @opendir($path) or die("Unable to open $path"); while ($file = readdir($dir_handle)) { if($file == "." || $file == ".." || $file == "index.php" ) { continue; echo "<ul><li><a href=uploads/$file>$file</a></li></ul>"; } } // Close closedir($dir_handle); ?> Maybe? Quote Link to comment Share on other sites More sharing options...
itsmeArry Posted March 2, 2007 Share Posted March 2, 2007 try print_r($file); and post here what you get Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 2, 2007 Share Posted March 2, 2007 Try this ok. <?php ob_start(); //path to the file $path = 'uploads/'; //file want to download. $file='result.php'; echo"<a href='test.php?cmd=page'>Get the page</a>"; if($_GET['cmd']=="page"){ $l = "$path$file"; header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header( "Content-Disposition: attachment; filename=".basename($l)); header( "Content-Description: File Transfer"); @readfile($l); } ob_end_flush(); ?> Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 2, 2007 Share Posted March 2, 2007 You say "this is the include function in my html page". If the name of the file that contains the include statement does not end with ".php", this will not work. I would do a "show source" on the generated HTML and see if there is a problem in the code. Ken 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.