Easiest way to extract images from a MS Word Document using PHP?

前端 未结 4 755
广开言路
广开言路 2021-01-06 23:48

Is this possible to extract images from MS Word Documents using PHP? And if so, how?

Requirement: Definitely old-shool doc support, but preferably both old and new.<

4条回答
  •  不要未来只要你来
    2021-01-07 00:31

    Create a new PHP file and name it as extract.php and add the following code in it.

    open($filename)) {
            for ($i=0; $i<$zip->numFiles;$i++) {
    
    
    /*Loop via all the files to check for image files*/
                $zip_element = $zip->statIndex($i);
    
    
    /*Check for images*/
                if(preg_match("([^\s]+(\.(?i)(jpg|jpeg|png|gif|bmp))$)",$zip_element['name'])) {
    
    
    /*Display images if present by using display.php*/
                    echo "
    "; } } } } readZippedImages($document); ?>

    Now create another PHP file and name it as display.php and add the following code to it.

    open($_GET['filename'])) {
    
    
    /*Get the content of the specified index of ZIP archive*/
            echo $zip->getFromIndex($_GET['index']);
        }
    
        $zip->close();
    ?>
    

    Source(s): Extracting Images from DocX using PHP

提交回复
热议问题