Following code is the updated version of the one from TotPeRo (thanks again for your code!), for last phpOffice (0.11) that has evolved a little/** * Set a new image * * @param string $search * @param string $replace */public function setImageValue($search, $replace){ // Sanity check if (!file_exists($replace)) { return; } // Delete current image $this->zipClass->deleteName('word/media/' . $search); // Add a new one $this->zipClass->addFile($replace, 'word/media/' . $search);}可以通过以下方式调用:Can be called with:$document->setImageValue('image1.jpg', 'my_image.jpg'); 这篇关于如何在PHPOffice/PHPWord模板上添加/设置图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!