I have created an image by copying a number of images into a new one. In the last step of my program, I am trying to export this file into a folder.
The code is as follows:
<?php
require_once "../shdp/simple_html_dom.php";
$next = "http://www.pidjin.net/2012/08/28/of-my-own/";
$html = file_get_html($next);
$imageList = $html->find('div[class=episode] p img');
$newHeight = 0;
for($iii=0; $iii<count($imageList); $iii++){
$storage[$iii] = $imageList[$iii]->src;
$img[$iii] = imagecreatefromstring(file_get_contents($storage[$iii]));
$width[$iii] = imagesx($img[$iii]);
$height[$iii] = imagesy($img[$iii]);
$newHeight += ($height[$iii] + 30);
}
$newWidth = max($width);
$cummDestHeight = 0;
$export = imagecreatetruecolor($newWidth, $newHeight);
imagefill($export, 0,0, 0xFFFFFF);
for($iii=0;$iii<count($img);$iii++){
imagecopy($export, $img[$iii], 0, $cummDestHeight, 0, 0, $width[$iii], $height[$iii]);
$cummDestHeight += $height[$iii] + 30;
}
$bits = explode('/',$next);
file_put_contents("../pidjin/$bits[5]-$bits[4]-$bits[3].png",$export);
?>
The error that I receive is this:
Warning: file_put_contents(): supplied resource is not a valid stream resource in E:\Web\Comics\pidjin.php on line 54
Problem: I am not sure how I can make $export a valid stream resource.