title: How to change image permission with PHP and chmod?
body: <p>As I want to display the uploaded images on website I get the message: "You don't have permission to access /funProject/uploads/328/20.jpg on this server".</p>
  
  <p>I had that problem before and I solved it with using <code>chmod</code> but somehow I deleted that solution and I can't make it now.</p>
  
  <p>I got a function like that:</p>
  
  <pre><code>function upload_image($image_temp, $image_ext, $album_id) {
    $album_id = (int)$album_id;
  
   mysql_query("INSERT INTO `images` VALUES ('', '".$_SESSION['user_id']."', '$album_id',  
   UNIX_TIMESTAMP(), '$image_ext')");
  
  
  $image_id = mysql_insert_id();
  $image_file = $image_id.'.'.$image_ext;
  move_uploaded_file($image_temp, 'uploads/'.$album_id.'/'.$image_file);
  
  create_thumb('uploads/'.$album_id.'/', $image_file, 'uploads/thumbs/'.$album_id.'/');
  }
  </code></pre>
  
  <p>What I have tried something like that (and doesn't work):</p>
  
  <pre><code>mysql_query("INSERT INTO `images` VALUES ('', '".$_SESSION['user_id']."', '$album_id', 
  UNIX_TIMESTAMP(), '$image_ext')");
  
  chmod($image_file, 0755);
  </code></pre>
  
  <p>How can I change the permission of the uploaded image with using <code>chmod</code> in this function?</p>