Access files outside public_html

Asked

Viewed 110 times

-2

I’m having a hard time with a Portable project, version of the 8.x. I deployed the project outside of public_html and everything of the project that was in the public folder I put inside the public_html of the server. but in the project when making an upload it falls into the project folder that is outside public_html so I cannot access these files. because the view can’t find the file.

Tree that uploads:

$filenameWithExt = $request->file('foto')->getClientOriginalName();
$filename = pathinfo($filenameWithExt, PATHINFO_FILENAME); 
$extension = $request->file('foto')->getClientOriginalExtension();
$fileNameToStore = $filename.'_'.time().'.'.$extension;
$path = $request->file('foto')->storeAs('public/upload', $fileNameToStore);
$data['foto'] = $fileNameToStore;

Trexo that is in the view:

src="{{asset('storage/upload/' . $user->foto)}}"

Folder structure
--project
----app
----public
----Storage
----the other folder of Laravel
--public_html
----the files from the public folder of the Laravel

1 answer

0


In fact you should not play the Laravel public files inside public_html of your server. You should normally leave it in the project folder and inside plublic_html point to the public of the terminal with . htaccess if you use apache.

Folder structure -project --app ---public ---Storage ----as Laravel’s other pasta --public_html ----. htaccess -> points to public/public project

  • got it... I did it this way Because that’s the way I saw it most in the content I researched. Thanks so much for the answer.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.