title: PHP where to save user uploaded image files
body: <p>currently i am saving user uploaded image files as follows:</p>
  
  <pre><code>public_html/img/user/$category/$username/$imagename
  </code></pre>
  
  <p>however, is this bad practice? Why is it bad to store in document root and where would a better place to store the files be?</p>
  
  <p>i filter extensions as follows:</p>
  
  <pre><code>    // Check to see if the type of file uploaded is a valid image type
  function is_valid_type($file)
  {
      // This is an array that holds all the valid image MIME types
      $valid_types = array("image/jpg", "image/JPG", "image/jpeg", "image/bmp", "image/gif", "image/png");
  
      if (in_array($file['type'], $valid_types))
          return 1;
      return 0;
  }
  </code></pre>