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?
–
–
–
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.