Code Beginner
Code Beginner

Reputation: 11

PHPExcel Load image from outside URL

Does anyone know how to make setPath() method able to load an image from outside server? Because all images is store on other server.I don't have any idea how to do that. Please help me. thanks

<pre>
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setPath('http://domain.com/images/testing.jpg');
$objDrawing->setHeight(96);
$objDrawing->setOffsetX(27);
$objDrawing->setOffsetY(40);
$objDrawing->setCoordinates('A9');
$objDrawing->setWorksheet($this->excel->getActiveSheet());
</pre>

Upvotes: 1

Views: 5602

Answers (2)

Mark Baker
Mark Baker

Reputation: 212412

Images can't be referenced from a URL, you need the image in your local filesystem because PHPExcel needs to extract information from that image. Use curl (or even file_get_contents()) to pull the image to the local filesystem first. Once the image has been embedded in the Excel document, you can delete the file again.

Upvotes: 3

Andrea Cristalli
Andrea Cristalli

Reputation: 1

You can put false as the second option in the setPath() method. Tcpdf gets the image from the URL and PHPExcel doesn't throw an exception.

Upvotes: -2

Related Questions