title: Error 403 on writing base64 on file with php
body: <p>I'm trying to decode a base64 string and write it to a file:</p>
  <pre><code>&lt;?php
      // requires php5
      define('UPLOAD_DIR', '/images/');
      $img = $_POST['img'];
      $img = str_replace('data:image/png;base64,', '', $img);
      $img = str_replace(' ', '+', $img);
      $data = base64_decode($img);
      $file = UPLOAD_DIR . uniqid() . '.png';
      $success = file_put_contents($file, $data);
      print $success ? $file : 'Unable to save the file.';
  ?&gt;
  </code></pre>
  <p>But the server gives this error message:</p>
  <blockquote>
  <p><strong>403 Forbidden</strong></p>
  <p>You don't have permission to access testupload.php on this server</p>
  </blockquote>
  <p>I have set all permissons for the php file and the images directory, so I don't understand why I get this error.</p>
  <p>When I put the decoded string of image directly inside the <code>$img</code> variable, it works and it creates the file under the images folder... But when I try to post the decoded string it doesn't work.</p>
  <p>How can I solve this?</p>
  <p>NOTE :
  when we try to send decoded string of image it may contain some virus or something like that from hackers ... i contact with my host providers and they say if you want we can turn of the modsecurity but its really unsafe way to do ... so what i have to do with this situation?</p>