why laravel needs to chmod() a file or folder after being created or uploaded?
<p>recently, I have deployed a web server configuration with Apache, PHP-FPM, and MariaDB. it was running smoothly until my colleague deployed laravel 4 app on it with image uploading capability.</p>

<p>The problem was I have disabled PHP's <code>chmod()</code> function along with <code>system()</code> etc functions, while the script for uploading images uses <code>chmod()</code> and <code>umask()</code> (my colleague said that this is the default behavior).</p>

<p>I know that there is a debate over the danger of <code>chmod</code> wih PHP like <a href="http://www.simplemachines.org/community/index.php?topic=2987.0" rel="nofollow noreferrer">this site</a> that tells it is harmless, and <a href="https://stackoverflow.com/questions/2338641/in-a-php-apache-linux-context-why-exactly-is-chmod-777-dangerous">this post</a> that tells that a server should never be 777</p>

<p>what I don't understand is, why do you need to <code>chmod()</code> something when the PHP process can read the uploaded file properly even without <code>chmod()</code>? it can even create folders and delete folders without <code>chmod()</code> as those files and folders are created with the correct permission for PHP process.</p>

<p><strong>tl;dr</strong><br>
so that brings to my question, is it true that file uploading in laravel 4 need <code>chmod()</code> to function properly? and why?</p>

<p><strong>edit</strong><br>
for those who like to know the code (this code is found in <code>vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/UploadedFile.php</code>):</p>

<pre><code>$target = $this-&gt;getTargetFile($directory, $name);

if (!@move_uploaded_file($this-&gt;getPathname(), $target)) {
    $error = error_get_last();
    throw new FileException(sprintf('Could not move file "%s" to "%s" (%S)', $this-&gt;getPathname(), $target, strip_tags($error['message'])));
}

@chmod($target, 0666 &amp; ~umask());
</code></pre>