title: PHP : add write permission to file after move_uploaded_file()
body: <p>After an image is uploaded with PHP, I want to make the image file writable in order to add a watermark to it . Here are the codes I used:</p>
  
  <pre><code>if(isset($_FILES['file_poster']['tmp_name']) &amp;&amp; $_FILES['file_poster']['tmp_name'] != '') {
          $random_filename = substr(md5(time()), 0, 9);
          $ext = '.jpg';
          if(strpos(strtolower($_FILES['file_poster']['name']), '.png') &gt; -1) {
              $ext = '.png';
          }
  
          move_uploaded_file($_FILES['file_poster']['tmp_name'], 'uploads/' .  $random_filename . $ext);
          chmod(ABS_PATH . $random_filename, 0666);
          $random_filename = 'uploads/' .  $random_filename . $ext;
  
          // add watermark codes omitted
  }
  </code></pre>
  
  <p>After the file is uploaded, the file permission becomes <strong>644</strong>. Then I tried to use <code>chmod()</code> to change it to writable ( <strong>666</strong> ), but the permission doesn't change.</p>
  
  <p>The <code>/uploads</code> folder has permission <strong>777</strong>. Is there any reason that makes <code>chmod()</code> function fails to change permission? or is there a workaround?</p>
  
  <p>Note: PHP 5 is used. GD is working properly.</p>