Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

priyasanka00's avatar

link app/public folder to public/storage folder

hi im new to laravel and cpanel please help me:

this is my controller and its working properly in localhost, but when i was upload it to cpanel others are working but not showing any images, in cpanel the laravel folder and public folder separately there:

$filename = $request->image->getClientOriginalName(); $filepath = str_replace('','/','storage/' . $filename); $request->image->storeAs('public',$filename);

0 likes
20 replies
priyasanka00's avatar

Warning: symlink(): No such file or directory in /home/adjuncti/public_html/symlink.php on line 4 Symlink process successfully completed

hi is that working properly?

Nakov's avatar

@priyasanka00 but can you see them in the public directory now? Can you show the code on how you reference them? Do you use the correct path?

priyasanka00's avatar

this is code:

$targetFolder = $_SERVER['DOCUMENT_ROOT'].'/storage/app/public'; $linkFolder = $_SERVER['DOCUMENT_ROOT'].'/public/storage'; symlink($targetFolder,$linkFolder); echo 'Symlink process successfully completed';

priyasanka00's avatar

ah this is my controller:

$filename = $request->image->getClientOriginalName(); $filepath = str_replace('','/','storage/' . $filename); $request->image->storeAs('public',$filename);

Nakov's avatar

A symlink should just create a file that points to the original directory, but not an actual directory.

Nakov's avatar

@fylzero that command exists a long time now, but as you can see in the original question, this is on a cPanel :)

priyasanka00's avatar

in Cpanel i think terminal is not provided: my localhost that your comand working

Nakov's avatar

@priyasanka00 I don't understand your requirement. This is how it should work.

You said the pictures are not displayed. I never saw a code on how you try to display them.

priyasanka00's avatar

namespace App\Http\Controllers;

use Illuminate\Http\Request; use App\form1;

class formcontroller extends Controller { public function store(Request $request ){

//dd($request->all());
//if ($request->hasFile('image'))
$this->validate($request,[
    'yourname'=>'required',
    'email'=>'required',
    'tp'=>'required|max:10|min:9',
    'subject'=>'required|max:41|min:4',
    'message'=>'required',
    'price'=>'required|numeric',
    'category'=>'required|numeric',
    'image'=>'required',
]);
$filename = $request->image->getClientOriginalName();
$filepath = str_replace('','/','storage/' . $filename);
$request->image->storeAs('public',$filename);
Nakov's avatar

@priyasanka00 so as it is works on localhost but not on the server right?

Now the question is did you run the file that you created from the link?

yoururl.com/symlink.php and did that said Successfully completed only on the page in the browser?

priyasanka00's avatar

yes it said like this:

Warning: symlink(): No such file or directory in /home/adjuncti/public_html/symlink.php on line 4 Symlink process successfully completed

Nakov's avatar

But there is an error, don't you see?

No such file or directory in /home/adjuncti/public_html/symlink.php

Did you created the file directly in the public folder? Are there enough permissions to run the file? Compare the permissions with the index.php file.

priyasanka00's avatar

thank you for your advice:

i changed root path acording to index.php in symlink.php as follows, now all imges are returned and link folder is aloso been created,

$targetFolder = $_SERVER['/laravel/bootstrap/autoload.php'].'/home/adjuncti/laravel/storage/app/public'; $linkFolder = $_SERVER['/laravel/bootstrap/autoload.php'].'/home/adjuncti/public_html/storage'; symlink($targetFolder,$linkFolder); echo 'Symlink process successfully completed';

Please or to participate in this conversation.