file_put_contents() is issuing an error when trying to export an image
<p>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. </p>

<p>The code is as follows:</p>

<pre><code>&lt;?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-&gt;find('div[class=episode] p img');

        $newHeight = 0;

        for($iii=0; $iii&lt;count($imageList); $iii++){
            $storage[$iii] = $imageList[$iii]-&gt;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&lt;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);
?&gt;
</code></pre>

<p>The error that I receive is this:</p>

<pre><code>Warning: file_put_contents(): supplied resource is not a valid stream resource in E:\Web\Comics\pidjin.php on line 54
</code></pre>

<p><strong>Problem</strong>: I am not sure how I can make $export a valid stream resource.</p>
