title: Specific file type allowed? php upload
body: <p>Im creating a image uploader, and i dont know how to do so only the filetype can be .jpg so im asking you, do you know it?</p>
  
  <p>heres what i got so far:</p>
  
  <pre><code>    &lt;?php
  session_start();
  if($_SESSION['username']) {
      $target_path = "users/$username/";
  
      $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
  
      if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
          echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
          "has been uploaded";
          header("Location: user.php");
      } else{
          echo "There was an error uploading the file, please try again!";
      }
  }
      else {
              echo "Only members can be here. Register &lt;a href='index.php'&gt;here&lt;/a&gt;";
    }
    ?&gt;
  </code></pre>
  
  <p>And one more thing, how may i rename the uploaded file to : "profile.jpg" ?</p>