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.<
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