Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get public directory?

I am a beginner here so pardon me for this question am using return File::put($path , $data); to create a file in public folder on Laravel. I used this piece of code from controller I need to know the value of $path how should it be.

like image 969
Yasser Moussa Avatar asked Feb 12 '13 16:02

Yasser Moussa


People also ask

How to give public folder path in Laravel?

For reference: // Path to the project's root folder echo base_path(); // Path to the 'app' folder echo app_path(); // Path to the 'public' folder echo public_path(); // Path to the 'storage' folder echo storage_path(); // Path to the 'storage/app' folder echo storage_path('app');

How do you change to public in HTML?

Run rm -r public_html . This command will delete public_html folder and all its contents. Make symbolic link ln -s $(pwd)/laravel/public $(pwd)/public_html . $(pwd) will be substituted with absolute path from root of the server.

Where is public path in Laravel?

The best way to retrieve your public folder path from your Laravel config is the function: $myPublicFolder = public_path(); $savePath = $mypublicPath. "enter_path_to_save"; $path = $savePath. "filename.


1 Answers

Use public_path()

For reference:

// Path to the project's root folder     echo base_path();  // Path to the 'app' folder     echo app_path();          // Path to the 'public' folder     echo public_path();  // Path to the 'storage' folder     echo storage_path();  // Path to the 'storage/app' folder     echo storage_path('app'); 
like image 72
Justin Avatar answered Sep 29 '22 15:09

Justin