PHP, Creating a folder when I run file_put_contents()
<p>I have uploaded a lot of images from the website, and need to organize files in a better way.
Therefore, I decide to create a folder by months.</p>

<pre><code>$month  = date('Yd')
file_put_contents("upload/promotions/".$month."/".$image, $contents_data);
</code></pre>

<p>after I tried this one, I get error result.</p>

<blockquote>
  <p>Message: file_put_contents(upload/promotions/201211/ang232.png): failed to open stream: No such file or directory</p>
</blockquote>

<p>If I tried to put only file in exist folder, it worked. However, it failed to create a new folder. </p>

<p>Is there a way to solve this problem?</p>
