Right guys... ive managed to get a working script....
[php]<?
//define the path as relative
$path = "/home/codanc/public_html/images/thedir";
//using the opendir function
$dir_handle = @opendir($path) or die("Unable to open $path");
echo "Directory Listing of $path<br/><br/>";
//running the while loop
while ($file = readdir($dir_handle))
{
echo "[img]http://www.yourweb.co.uk/images/thedir/";
echo "$file";
echo "[/img]<br/><br/>";
}
//closing the directory
closedir($dir_handle);
?> [/php]
Now this is really simple and everytime I upload a new folder full of images I have to login to my ftp and change the code around...
Would it be possible to make it so that when I run it... it shows a text box... then all i do is enter the path to the directory I want the output to be for??
Thanks again
php Related question.
Last edited by nads on 18 Sep 2006, 13:41, edited 1 time in total.
- Noobarmy
- Past Contributor
- Posts: 545
- Joined: 02 Jun 2006, 11:19
- Real name: Anthony Chu
- Location: UK
- Contact:
Ok screw it i'll just tell you what to make it
Replace your file with the following:
[php]<?
//define the path as relative
$path = $_GET['PATH'];
//using the opendir function
if ($path != '')
{
$dir_handle = @opendir($path) or die("Unable to open $path");
echo "Directory Listing of $path<br/><br/>";
//running the while loop
while ($file = readdir($dir_handle))
{
echo "[img]" . $path;
echo "$file";
echo "[/img]<br/><br/>";
}
//closing the directory
closedir($dir_handle);
}
else
{
$file = basename(__FILE__);
echo '<html><head></head><body><form action="' . $file . '" method="GET"><input type="text" value="" name="PATH" /></form></body></html>';
}
?>[/php]
Replace your file with the following:
[php]<?
//define the path as relative
$path = $_GET['PATH'];
//using the opendir function
if ($path != '')
{
$dir_handle = @opendir($path) or die("Unable to open $path");
echo "Directory Listing of $path<br/><br/>";
//running the while loop
while ($file = readdir($dir_handle))
{
echo "[img]" . $path;
echo "$file";
echo "[/img]<br/><br/>";
}
//closing the directory
closedir($dir_handle);
}
else
{
$file = basename(__FILE__);
echo '<html><head></head><body><form action="' . $file . '" method="GET"><input type="text" value="" name="PATH" /></form></body></html>';
}
?>[/php]
Return to “General Discussion”
Who is online
Users browsing this forum: No registered users and 5 guests