Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder che_anj's Avatar
    Join Date
    Aug 2006
    Location
    Philippines
    Posts
    157
    Thanks
    12
    Thanked 3 Times in 3 Posts

    view document file into html format

    Hello i get this example code and I try but it doesnt work. could anyone pls help me what to do with this..
    This is to view the document file into html format..

    <?php
    $PathToDocumentFolder = '/var/www/web23/web/main/cvs/';
    ?>
    <html>
    <head>
    <basefont face="Arial">
    <title>My Documents</title>
    </head>
    <body>
    <h2>My Documents</h2>
    <table border="2" cellpadding="5" cellspacing="1" width="90%">
    <tr>
    <th>Name</th>
    <th>&nbsp;</th>
    <th>&nbsp;</th>
    </tr>
    <?php
    $dHandle = dir($PathToDocumentFolder);
    while($dContent=$dHandle->read())
    {
    if(substr($dContent,-4)== ".doc")
    {
    ?>
    <tr>
    <td width="55%" align="left"><?php echo $dContent;
    ?></td>
    <td width="20%" align="center"><a href="<?php echo
    $PathToDocumentFolder." ".$dContent; ?>">View as Word</a></td>
    <td width="20%" align="center"><a href="<?php echo
    "htmlviewer.php?DocumentPath=".$PathToDocumentFolder." ".$dContent;
    ?>">View as HTML</a></td>
    </tr>
    <?php
    }
    }
    // close the handle to the directory
    $dHandle->close();
    ?>
    </table>
    </body>
    </html>


    this is the link http://testserver.indigo21.com/mydesign/views.php
    tnx

  • #2
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    you have a space in the filenames which sends a 404 for word doc and the path couldnt be found by php
    PHP Code:
    <a href="<?php echo
    'htmlviewer.php?DocumentPath='.$PathToDocumentFolder.''.$dContent;
    ?>">View as HTML</a>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •