title: How to Create a directory and file in Laravel
body: <p>I would like to achieve localization in laravel <a href="https://laravel.com/docs/5.8/localization" rel="nofollow noreferrer">https://laravel.com/docs/5.8/localization</a></p>
  
  <p>I would want to allow a user to set up a .json file and upload the key value translations. </p>
  
  <p>To achieve this, I need to create a directory on <code>resources/lang/' . $request-&gt;language</code> that is <code>$path = base_path('resources/lang/' . $request-&gt;language . '/');</code> then a json file <code>$request-&gt;language. '.json'</code></p>
  
  <p>I tried this </p>
  
  <pre><code>File::makeDirectory(base_path()."'resources/lang/' . $request-&gt;language . '/'", $mode = 0777, true, true);
  </code></pre>
  
  <p>Then </p>
  
  <pre><code>//Write File
  $newJsonString = json_encode($request-&gt;translation, JSON_PRETTY_PRINT);
  file_put_contents(base_path($path . $request-&gt;language. '.json'), stripslashes($newJsonString));
  </code></pre>
  
  <p>For some reasons, it does not create even the directory. Could I be missing something?</p>