title: Delete folder that contains files from s3 bucket php
body: <p>Im trying to delete a folder in an s3 bucket that is located in a folder called CreativeEngine the folder structure looks like this CreativeEngine/8943
  I want to delete the folder with the called 8943 but it contains files within it. Do I need to do some kind of loop to delete the files first or can I delete the folder? I tried this but it didn't work </p>
  
  <pre><code>    &lt;?php 
  $itemId=$_GET['id'];
      require('s3/vendor/autoload.php');
          use Aws\S3\S3Client;
          use Aws\S3\Exception\S3Exception;
          // AWS Info
          $bucketName = 'mybucket';
          $IAM_KEY = 'mykey';
          $IAM_SECRET = 'mysecret';
          // Connect to AWS
              $s3 = S3Client::factory(
                  array(
                      'credentials' =&gt; array(
                          'key' =&gt; $IAM_KEY,
                          'secret' =&gt; $IAM_SECRET
                      ),
                      'version' =&gt; 'latest',
                      'region'  =&gt; 'us-east-2'
                  )
              );
  
  
      $s3Destination='CreativeEngine/'.$itemId;
      $keyName = $s3Destination;
  
      try{
      $s3-&gt;deleteObject(array(
          'Bucket' =&gt; $bucketName,
          'Key'    =&gt; $keyName
      ));       
      } catch (S3Exception $e) {
      $data['message']='&lt;li&gt;error'.$e-&gt;getMessage().'&lt;/li&gt;';
      }
      ?&gt;
  </code></pre>