Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There are two possible meanings for "executable" in this context, and both are things you need to configure against.</p> <ol> <li><p>An executable binary file that may run from the command line by typing the file's name into a shell</p></li> <li><p>A file that may be <em>read</em> and processed as script by a web server.</p></li> </ol> <p><strong>Handling binary-executable</strong></p> <p>To configure against case 1 on a un*x system, you need to ensure that your upload directory, and files therein, are owned by the web server user and only readable by that user. The directory must be executable; this means that the files inside that directory can be accessed). If the web user needs to list the files in the directory, it must also be readable. It, of course, must also be writable to allow new files to be created. </p> <p>Thus the octal set you want would be </p> <pre><code>chown &lt;web-server-user&gt; &lt;upload-dir&gt; chmod 0700 &lt;upload-dir&gt; </code></pre> <p>The files must not be executable and should only be readable and writable by the web server,so these should be </p> <pre><code>chmod 0600 &lt;uploaded-file&gt; </code></pre> <p>Please note that this means that <em>only the web server user</em> will be able to see these files. This is the best situation for security. However, if you really do need other local users to be able to see these files,then use</p> <pre><code>chmod 0755 &lt;upload-dir&gt; chmod 0644 &lt;uploaded-file&gt; </code></pre> <p><strong>Handling web-server excutable</strong></p> <p>Coding against case 2 is web server specific. </p> <p>One option is to place the upload directory outside of the webroot, dissalowing direct URL access to the uploaded files completely and only to serve them via server-side code. Your code reads and echoes the file content, thus ensuring it is never processed as script by the web server</p> <p>The other option is to configure your web server to not allow script processing of files in the upload directory. This configuration is web-server specific. However, for example, in Apache you can achieve this this by entering into your server configuration:</p> <pre><code>&lt;Directory "path-to-upload-dir"&gt; AllowOverride None Options -ExecCGI &lt;/Directory&gt; </code></pre> <p>AllowOverride None is important, as it stops anyone uploading a .htaccess file to your uploads directory and re-configuring the web server permissions for that directory.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload