Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Linking to local files in a HTML page

Options
  • 30-11-2006 3:53pm
    #1
    Closed Accounts Posts: 23


    I have a PHP/MySQL/Apache server(WAMP) running on my local PC at the moment. I wrote a php script today that catalogues all the files in a folder and its subfolders. This is fine, except that MySQL seemingly can't store a "\", presumably because its UNIX based. That's really not a big problem, seen as i can just echo the results to the screen, and then use a text editor to replace the \'s with /'s.

    However, when i try to create a HTML page with php on it, i can't figure out how to link to the local files. What i want to is create a directory listing(which'll be stored in a database) of all the files in a folder, and have each one represented as a link in the HTML page. However, when i try make a normal link, like this
    <table bgcolor=#ffffff cellpadding=1 cellspacing=1 border=2>
    <?php
    echo "<P><tr>
    <td><b>Filename</b></td>
    </P>";
    $block = "<P><tr><td><a href='c:\wamp\www\dossier.gif'>c:\wamp\www\dossier.gif</a></td></P>";
    echo($block);
    ?>
    </table>

    I get back
    Firefox doesn't know how to open this address, because the protocol (c) isn't associated with any program

    Which i can understand where its coming from. However, when i then try to make the link like this
    <table bgcolor=#ffffff cellpadding=1 cellspacing=1 border=2>
    <?php
    echo "<P><tr>
    <td><b>Filename</b></td>
    </P>";
    $block = "<P><tr><td><a href='file:///c:/wamp/www/dossier.gif'>file:///c:/wamp/www/dossier.gif</a></td></P>";
    echo($block);
    ?>
    </table>

    which is apparently the way you're supposed to do it, nothing happens when i click the link.

    Any ideas for this, and also, if possible if there's a workaround for the first problem?


Comments

  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    Don't use absolute references, use relative ones instead.

    Use the ../ notation to move to the first common root that the directories use, and speficy each directory from there, or use the ./ notation if the file is in the same directory as your page.


  • Closed Accounts Posts: 23 doc_1982


    See thats the problem(i think).

    WAMP operates its localhost from a directory on the C drive called Wamp. The files i want to catalogue aren't necessarily going to be in that directory. So when i try to run a php script that generates links for every file in the database, any relative linking is going to be from inside c:\wamp\www\, so this won't work, unless i'm understanding you wrong.


Advertisement