On a Web Page, How Do I...

The Rocketry Forum

Help Support The Rocketry Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

11bravo

Well-Known Member
Joined
Jan 18, 2009
Messages
2,748
Reaction score
3
grburnett.us/rockets
gets you to my rockets page.
There is more in that folder than on the web page, without editing the page to reflect all the folder contents, how do I make the contents available?
As in, I'd like to put a link at the bottom that would go to a text version, something like this link:
https://grburnett.us/rockets/textpage.jpg

Spank ya,

Greg
 
Most web servers require an index.html or index.htm as the "main" page for a website.

If you do not have that, it may list a default page, or in your case, a directory listing.


So get a web page editor, create a web page that shows what you want it to show, name it index.htm(l) and upload it to your website.
 
Are you trying to put that on the bottom of a regular HTML page? Try this PHP:

PHP:
-html goes here-
<?php
// get local directory path
$path= dirname($_SERVER['SCRIPT_FILENAME']);
?>
<h3>Files in <?php print $path; ?>:</h3>
<ul>
<?php
$d = dir($path);
while (false !== ($entry = $d->read())) {

    if ( substr($entry, 0, 1)=='.' ) continue;
    // find filename extension
    $dotpos = strrpos($entry, '.');

    if ($dotpos) {
        $ext = substr($entry, $dotpos+1);   
    }
    print "<li><a href='$entry'>$entry</a></li>\n";   
}
$d->close();
?>
</ul>
-more html-

I haven't tested this code yet, but it should work.
 
Try re-naming the home page index.htm or index.html
 
First, let me say, I screwed up.
If you used the link I posted you got the directory listing that I would like to be able to get.
I had renamed my index.htm to index.htm.old so that it would not be found and would give the directory.

Matt-
Didn't work.
Thanks.
 
It works for me. Does your website have PHP? Make sure you copy it into a file with a .php extension.
 
Sorry, missed your reply earlier.
That might be the problem; I need it to go into an html file.
I'll dig around and see what I can find.
 
The cool thing about PHP is that the rest of the file can be HTML. The <?php ... ?> part acts just like another HTML tag (except that it is converted to HTML by the server). So put the snippet of code where you want it in the HTML file and change the extension to .php
 
Back
Top