View Full Version : Small HTML question; index w/ what I have in a FTP space
EZ_Bondori Zafiro
12-17-03, 12:32 PM
How can I make an index page that just displays everything I have in a FTP space?
Here is an example of what I'd like.
I know it's just a simple thing, but doing searches on Google for HTML help gets me a bunch of stupid links to books on how to. Confound you, Google! Edited by: Bondori Zafiro at: 12/17/03 12:33 pm
freonsmurf
12-17-03, 12:47 PM
you can delete the index.html file in your main directory.
I guess you use your ftp for file space? whats the link to your webpage?
if you use it as something else. move the files you need to another directory, then when you browse there they will appear like the link above.
example with index.html
flamevault.com/~hobbit/
and without index.html
flamevault.com/~hobbit/crapolla/
hey look its my website? why dont you say something on the shout box! hehe...sorry
Some internet providers, however, will prevent directory viewing by default, and if someone tries to view a directory without an index file it'll bounce them to an error page instead. If that's what's happening, you may wanna get a hold of your ISP and find out if you can disable this autobounce and enable directory viewing for your web space. Amadan :: Child of the Phoenix ::
tunare()warden
"You're nothing but barbarians, scoundrels, and assassins!"
"And fools. Don't leave out fools."
EZ_Bondori Zafiro
12-17-03, 02:52 PM
Yep, that must be what's happening.
Oh well, it wasnt really important anyway.
It was hosted on comcast.
Of course you can always make a page listing what you have in the folder and create links to the items.
EZ_Hordolin Awanagin
12-18-03, 08:44 AM
<?php/**        * array getFolder(string $path[, int $sort])        *        * Gets a list of files and returns them in a multidimensional array having the format        *        * $array['dir'][] = "directory";        * $array['file'][] = "filename";        *        * $path is a string containing a valid path on the local filesystem        * $sort is an integer with a value of 1 or 0, 1 sorts in descending order, 0 sorts in ascending.        * $sort defaults to ascending order if omitted        *        **/        function getFolder($path, $sort = 0){                // typecast our integer, to be on the safe side        $sort = (int)$sort;                // check to see if there was a trailing slash. if no slash, add one        if (substr($path, -1) != '/')        {                $path.='/';        }                // confirm that the path exists        if (!file_exists($path))        {                die("$path does not exist" ;        }                // confirm that the path is readable        elseif (!is_readable($path))        {                die("no permissions to view $path with this user" ;        }                // confirm that $path is a directory        elseif(!is_dir($path))        {                die("$path is not a directory" ;        }                        $directory = array();        $hp = opendir($path);        // build a multidimensional array of files and folders        while (false !== ($file = readdir($hp)))         {                if (($file!='..') && ($file!='.'))                {                        if (is_dir($path.$file))                        {                                $directory['dir'][] = $file;                        }                         elseif (is_file($path.$file))                        {                                $directory['file'][] = $file;                        }                }        }                switch($sort)        {                case 1:                        arsort($directory['dir']);                        arsort($directory['file']);                break;                default:                        asort($directory['dir']);                        asort($directory['file']);                break;        }                reset($directory['dir']);        reset($directory['file']);                return $directory;} // end function getFolder()$files = getFolder('/path/to/your/files');// IMPORRTANT NOTE: A lot of people will be tempted to use foreach() here. It's strongly// suggested that you don't unless you need to modify the array while looping over it.// The reason you shouldn't is that PHP will make a copy of the array needlessly to loop over.// each() on it's own does not have that effect.while (list($key, $val) = each($files['dir'])){        echo "[$val]<br>";}while (list($key, $val) = each($files['file'])){        echo '<a href="web/path/to/files/'.urlencode($val).'">'.$val.'</a><br>';}?>
freonsmurf
12-18-03, 10:15 AM
got an example of what that looks like in use?
is it a Linux server??
if so use an .htaccess file to allow index viewing..
<Directory /directory/path/> Options Indexes Allow from all AllowOverride All Order allow,deny </Directory>
you will also have to rename your index.htm(l) file as Wix mentioned and as shown in the example you provided (!Index.html)
Edited by: Aidden at: 12/18/03 10:29 am
EZ_Bondori Zafiro
12-18-03, 10:41 AM
Not a linux server, I'm afraid.
If it is they specifically disallow .htaccess files from being uploaded (nothing can begin with a period).
I figured that out when I was implementing my dynamic avatar, the .htaccess file is part of it =P had to use another host.
Mother fugging spelling. Edited by: Bondori Zafiro at: 12/18/03 10:42 am
EZ_Bondori Zafiro
12-18-03, 01:07 PM
Well, I was just using the FTP space comcast gave me to host all my online cruds.
I had to use the 1and1 host for my avatar though.
I'm cheap, and not really in need of hosting other then file storage. So nothing is just about all I'm willing to pay ;D
EZ_Hordolin Awanagin
12-18-03, 01:57 PM
Freon: no :/ don't have .php on any of the unix machies here. it's just plain text output though.
Bondori: where are you putting the page? Does the server you're putting it on support any type of script processing?
Below is .asp to do it. with graphics (graphics not included, name the pictures xxx.jpg where xxx is the extension the picture is supposed to represent.
Folders<br><%Set directory=server.createobject("scripting.filesystemobject") Set allfiles=directory.getfolder(server.mappath("directories/") )' Lists all the files found in the directoryFor each directoryfile in allFiles.subfolders%><% ' Removes certain MSFrontPage was directories if right(directoryfile.Name,3) <> "cnf" then %><a href="directories/<% =directoryfile.Name %>" target="_blank"><% =directoryfile.Name %></a><br><% end if %><% Next %><br>Files<br><% ' Lists all the files found in the directoryFor each directoryfile in allFiles.files %><a href="directories/<% =directoryfile.Name %>"><% ext=right(directoryfile.Name,3)select case ext case "pdf","asp","htm","mdb","xls","ppt","doc","txt" %><img src="directories/images/<%= ext %>.jpg" border="0"><% case else %><img src="directories/images/unk.jpg" border="0"><% end select %><% =directoryfile.Name %></a><br><% Next %>
EDIT: emoticon extermination
Edited by: Hordolin Awanagin at: 12/18/03 2:03 pm