title: mkdir(): Permission denied Laravel
body: <p>I'm running the following script for an image upload in a server and getting the following error while it works perfectly on the localhost. </p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>$user_id = Auth::id();
  $logicpath = 'userdp/' . $user_id . '/';
  $pubpath = 'userdp/' . $user_id . '/' . $dpFile;
  $path = '/userdp/' . $user_id . '/' . $dpFile;
  
  if (!file_exists($logicpath)) {
       mkdir($logicpath, 0777, true);
  }
  </code></pre>
  
  <p><strong>Error</strong></p>
  
  <blockquote>
    <p>ErrorException in UploadController.php line 605: mkdir(): Permission
    denied</p>
    
    <p>at HandleExceptions->handleError('2', 'mkdir(): Permission denied',
    '/var/www/html/laravel/app/Http/Controllers/UploadController.php',
    '605', array('dp' => object(UploadedFile), 'ext' => 'jpg', 'img' =>
    object(Image), 'mime' => 'image/jpeg', 'width' => '200', 'height' =>
    '200', 'fileSize' => '17152', 'dpFile' =>
    'f12f298ab18d58a59c4ed8a589cd1cdc.jpg', 'user_id' => '1', 'logicpath'
    => 'userdp/1/', 'pubpath' => 'userdp/1/f12f298ab18d58a59c4ed8a589cd1cdc.jpg', 'path' =>
    '/userdp/1/f12f298ab18d58a59c4ed8a589cd1cdc.jpg'))</p>
  </blockquote>
  
  <p>I tried <code>chmod 777 public</code> and restarted the server. But it didn't work. </p>