Symlink(): no such file or directory because public folder is in a different directory
Problem solved by placing my html_root content back to my private folder in /home/user/private/application
and creating a symlink of my public folder that goes to my /home/user
and renaming the /home/user/public
folder to /home/user/html_root
(and keeping the symlink intact).
So i remain with the official Laravel directory structure and make a faux (symlink) of the public folder.
With this i can use the php artisan storage:link
normally without creating a custom Command.
problem with symlink in Hostinger with laravel
after one year of suffering from Hostinger, finally, I just upgrade to Business shared hosting, and now everything working well .... this command is run successfully :
PHP artisan storage:link
php artisan storage:link on shared Hosting is not showing images
Go to /public directory and run:
rm storage
Go to Laravel root directory and run:
php artisan storage:link
This problem comes when laravel project is moved/copied to some other folder.
The storage link is still there thus causing the exception error. public/storage folder exists and points to wrong location and it needs to be deleted with rm storage command.
After that run php artisan storage:link in terminal and it will create the storage link.
This needs to be done EVERY time when laravel is moved/copied/deployed!
laravel storage link not working on another system
I'm using a shared hosting service and move everything in laravel's public directory into hosting's public_html and move everything beside laravel's public directory into a new folder I generate in the same directory as the public_html directory such as below:
- root / parent directory
- public_html
- laravel
Make a file in public folder named symlink.php which contains this code:
<?php
$targetFolder = '../laravel/storage/app/public';
$linkFolder = $_SERVER['DOCUMENT_ROOT'].'/storage';
if(symlink($targetFolder,$linkFolder)){
echo 'Symlink completed';
} else {
echo 'Symlink Failed';
}
?>
you can specify the $targetFolder variable to your storage/app/public path like above.
afterwards call the file through your laravel link.
eg:
http://mylaravel-example.com/symlink.php
nb : the file's name is not a fixity, you can specify it as you desired.
Symlink storage link from Laravel doesn't work as expected
It seems you are using the default disk which is local
that stores the files in storage/app
directory as configured in config/filesystems.php
, but what you want is public
disk which stores the files in storage/app/public
that is linked to the public directory by running php artisan storage:link
.
So here are some solutions:
Specify which disk you want to use:
$request()->file('logo')->store('uploads/clients', ['disk' => 'public']);
OR
- Create a new disk in
config/filesystems.php
and link it with youruploads/clients
then change the defaultFILESYSTEM_DRIVER
inconfig/filesystems.php
to the new disk.
OR
- Change the default
FILESYSTEM_DRIVER
topublic
inconfig/filesystems.php
.
Related Topics
Is There a Function to Make a Copy of a PHP Array to Another
How to Design a Hierarchical Role Based Access Control System
Combining and Compressing Multiple JavaScript Files in PHP
Detect "Overall Average" Color of the Picture
Clean Way to Throw PHP Exception Through Jquery/Ajax and JSON
How to Detect and Handle MySQL Warnings with PHP
Add a Checkout Checkbox Field That Enable a Percentage Fee in Woocommerce
Symfony2 - How to Switch from "Dev" to "Prod"
How to Send JSON Response in Symfony2 Controller
Permission Denied Despite Appropriate Permissions Using PHP
PHP Error: "The Zip Extension and Unzip Command Are Both Missing, Skipping."
Securing a Rest API Accessible from Android
How to Properly Display Chinese Characters in PHP
How to Work with Many-To-Many Relations in Yii2
Checking for Empty Arrays: Count VS Empty