Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I simple just can't get this to work in Laravel 5. and furthermore Laravel doesn't give me any errors to work with. I have build a small CMS system where users are allowed to create a gallery page. When the gallery page is created it should create a folder for the user as well.

$path = public_path('/userfiles/3/Galleri/1');
File::makeDirectory($path, 0777, true);

I'm trying this, and tried different other approaches. I'm working in Laravel 5 and on a shared host, if that has anything to do with it.

Hi Jonju I have yes. I dont know if it's because of the shared hosting, that it might be adding the folder some weird place? :) – Mads Grevit Aug 4, 2016 at 19:08
use File;
$path = public_path('/userfiles/3/Galleri/1');
File::makeDirectory($path, 0777, true);
$path = public_path('/userfiles/3/Galleri/1');
\File::makeDirectory($path, 0777, true);

You should check it before create directory

$path = public_path('/userfiles/3/Galleri/1');
    if(!File::exists($path)) {
        File::makeDirectory($path);
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.