title: PHP set file to read/download only
body: <p>To keep things short, I'm making a very simple file uploading script. What I need to do, is take the file that was just uploaded, save it to the directory that is specified, and make the file read only/non executable. Why? Well, if somebody were to upload a PHP script to show somebody, the script wouldn't be allowed to run, instead, it would just show the actual text of the file.</p>
  
  <p>I've been trying to do this with chmod(), but nothing has worked.</p>
  
  <pre><code>$target_directory = "./" . $_POST["directory"] . "/"; // The target directory to put the file.
  
  $file_name = $_FILES["file"]["name"]; // The name of the file being uploaded (Example: file.ext)
  
  $target_file = $target_directory . $file_name; // The more compiled target file/location. (Example: /folder/file.ext)
  
  if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_file)) {
      echo "The file was uploaded. at &lt;a href='" .$target_file ."'&gt;".$target_file ."&lt;/a&gt;";
      chmod($target_file, 0644);
  </code></pre>
  
  <p>What kind of code would I need to write to make <code>chmod()</code> work, or to set the directory/file to not execute?</p>