Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save Kristjan-Reinsberg/707a48fca4fd814541671d3e4fad686e to your computer and use it in GitHub Desktop.

Select an option

Save Kristjan-Reinsberg/707a48fca4fd814541671d3e4fad686e to your computer and use it in GitHub Desktop.
LARAVEL STORAGE LINK IN SHARED HOSTING
<?php
#Please note that project folder is one level from public_html (/../projects/laravel/)
#Plese note that laravel public folder files must be in public_html (configure the location)
#1 Remove storage folder in public_html/public/storage if you perfomed storage:link in local
#2 Create a php file: mysymlink.php @ public_html folder
#3 Add below codes to mysymlink.php file
$targetFolder = $_SERVER['DOCUMENT_ROOT'].'/../projects/laravel/storage/app/public';
$linkFolder = $_SERVER['DOCUMENT_ROOT'].'/storage';
symlink($targetFolder,$linkFolder);
echo 'Symlink @ Cpanel type virtual host completed (var_dump to be sure)';
/* NOT SURE ABOUT PATH? Test like so.
@public_html folder run this in some file:
$target_folder = $_SERVER['DOCUMENT_ROOT'].'/../projects/laravel'; //go one back from public_html
$files_in_folder = scandir($targetFolder);
print_r($files_in_folder);
*/
@hirezadehghani
Copy link

You are saving my Life!
So Thanks man :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment