0

Hi all, i have a table in db which contain some pdf and docx files.
Am trying to display it in a way, so that when the user click on it, it will load the pdf and/or docx file from db in another/same window.

this is what i have done so far:

<?php
        $query = "SELECT image_file, note_title, note_commt FROM notez WHERE svreg = '".$svreg."'";
        $result = mysql_query($query) or die('Error, query failed');
        while(list($image_file, $note_title, $note_commt) = mysql_fetch_array($result))
        { ?>

        <img src="<?=$image_file?>" width='30' height='30' class='thumbnail' title='<?=$title?>'>                                                                      
        <?php } ?>
4
Contributors
6
Replies
40
Views
3 Years
Discussion Span
Last Post by pzuurveen
0

thank for the code IIM, i tryed it

echo '<pre>';
//echo "starting\n";
                    set_time_limit (30); //to allow time for Word to load.
                    $word = new COM("word.application") or die ("Could not initialise MS Word object.");
                    echo "COM instantiated\n";
                    $word->Application->Visible = False; 
                    echo "set visibility to false\n";

                    $doc = "src='userimages_doc/1364905979.3535.doc'";
                    $document = reapath($doc);
                    //if (is_readable($document)
                    echo "Document exists and is readable \n";
                    //else:
                    if(!is_file($document)):
                    echo "Document does not exist\n";die();
                    else:
                    echo "Document is not readable\n"; die();
                    endif;
                    //endif;
                    $word->Documents->Open( $document ); 
                    echo "Document opened\n";
                    // Extract content. 
                    $content = $word->ActiveDocument->Content; 
                    echo "test\n----------\n";
                    print_r($content);
                    echo "test\n----------\n";
                    echo "Extracting string value of content\n";
                    $content = (string) $content;
                    echo "test\n----------\n";
                    echo $content;
                    echo "test\n----------\n";

                    echo $content; 

                    $word->ActiveDocument->Close(false); 
                    echo "Closed Document\n";
                    $word->Quit(); 
                    //echo "Quit Word \n"
                    $word = null; 
                    unset($word);

                    //}

but i keep getting this error

Fatal error:  Call to undefined function reapath() in D:\xampp\htdocs\auto-habari\admin\userindex\vehicles\veh_over_view.php on line 441

i do not know if it have anything to do with this code

 $doc = "src='userimages_doc/1364905979.3535.doc'";

Edited by dannybarh

0

typo for realpath()

should test on the dir name only

    $doc="userimages_doc/1364905979.3535.doc";
    $dir=pathinfo($doc);
    $document=realpath($dir['dirname']).DIRECTORY_SEPARATOR.$dir['basename'];

Edited by pzuurveen

0

thanks pzuurveen for the help, this is what i get

COM instantiated
set visibility to false
Document exists and is readable 
Document is not readable

can you pls tell me what it means, cos am not sure if the scprit is working

0
if (is_readable($document)) {
    echo "Document exists and is readable \n";
    }
else {
    if(!is_file($document)) {
        echo "Document does not exist\n";
        die();
        }
    else {
        echo "Document is not readable\n"; 
        die();
        }
    }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.