title: PHP -- Can't view image after uploading it to created directory
body: <p>After looking through several posts on here and as well as Google, I've yet to find a solution to my problem. I'm making a website where a user can upload images. If no personal directory exists for their images, I create one and place the image inside. The issue is that after the directory is made and the image is inside, I can't view it because I don't have the correct permissions once I navigate to that folder and try to open it. I've seen several people with the same issue, and none of the solutions I've found worked for me.</p>
  
  <p>I'm aware I need to check things like size, type, if it already exists, etc. At this point, I'm just trying to see the image.</p>
  
  <p><strong>EDIT</strong>: Changed permissions from 0777 to 0755, but the issue remains. <br>
  <strong>EDIT2</strong>: fileperms returns 33206 when run on the uploaded image.</p>
  
  <pre><code>if(isset($_POST["submit"])) 
      {
          $path = "images/$user_id";
  
          if(!file_exists($path))
          {
              mkdir($path, 0755, true);
          }
  
          $target_dir = "$path/";
          $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
          $uploadOk = 1;
          $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
  
          $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
          if($check !== false) 
          {
              echo "File is an image - " . $check["mime"] . ".";
              $uploadOk = 1;
          } 
          else 
          {
              echo "File is not an image.";
              $uploadOk = 0;
          }
  
          if(move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file))
          {
              chmod($path . "/" . $_FILES["fileToUpload"]["name"], 0755); 
              echo "The file was upload successfully.";   
          }
          else
          {
              echo "There was an error with the upload.";
          }
      }
  </code></pre>