相关文章推荐
叛逆的番茄  ·  Implement HTTP call ...·  1 年前    · 
无聊的莴苣  ·  如何删除SQL ...·  1 年前    · 
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 am getting confused with this logic. I am using Laravel 5.2 Storage::makeDirectory to create two paths, first ( video/ ) is created correctly and the other ( thumbnails/ ) don't.

$user = 1;
if(!File::exists(public_path() . "/video/$user"))
    Storage::makeDirectory(public_path() . "/video/$user", 0777);
$file = rand(1111111111111, 9999999999999);
$imgpath = public_path() . "/thumbnails/$file";
if(!File::exists($imgpath))
    Storage::makeDirectory($imgpath, 0777);

Here is the permission configuration:

drwxrwxrwx 2 ubuntu ubuntu 4096 Jun 28 19:33 thumbnails/
drwxrwxrwx 3 ubuntu ubuntu 4096 Jun 29 15:21 video/

I also could create a directory from cli with the given string from $imgpath:

mkdir /home/ubuntu/workspace/site/public/thumbnails/6300643852187

Any suggestions?

Hm... i don't see any errors at now, can you just try to do mkdir($imgpath, 0777, false); without any conditions? – GONG Jun 29, 2016 at 16:25 can you provide $imgpath listing, please? (i know this is different each time, but anyway i need to see it) – GONG Jun 29, 2016 at 16:40 it does not contain anything, since the paths aren't being created because of... Idk... That is my question indeed. Why. – user3018216 Jun 29, 2016 at 20:17
if(!Storage::disk('public')->has('image/path/directory/')){
    Storage::disk('public')->makeDirectory('image/path/directory/');
$dr = $_SERVER['DOCUMENT_ROOT'];
$is_dir = File::makeDirectory($dr.'/uploads/images/'.$user.'/thumbs/', 0755, true, true);

0755 is folder permissions

1st true is recursive creation of folders

2nd true is to force it to do it

Well... I figured out what was going on.

File::exists(public_path() . "/video/$user") is looking for this:

/home/ubuntu/workspace/site/public/video/N

And Storage::makeDirectory(public_path() . "/video/$user") is creating a directory in:

/home/ubuntu/workspace/site/storage/app/public/video/N

So I can go to site/config/filesystems.php and change the routes for app and app/public ; you can check them by using the helper storage_path('app').
But, instead, I decided to save the videos in the storage/app/public/video and storage/app/public/thumbnails, and I am getting some package's error.

But, both paths are writable and should be working by now.

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.