How can I save documents in the public_html folder on my server?
I'm trying to save images but I can not get it, in my localhost it works fine, I attach my code:
if($request->hasFile('img')){
$file = $request->file('img');
$name = $file->getClientOriginalName();
$path = public_path() .'\img\controles';
$file->move($path,$name);
}
dd($path) =C:\xampp\htdocs\login\public\img\controles
the structure of my project in local is like this
- login
- app
- public
- img
- controls
- img
in local I have no problems, everything works fine, I have the problem when I migrate it to the server, here is the structure of the project
- login
- app
- public_html
- css, js
- img
- controls
this is my code (the same as above, just change the 'path')
if($request->hasFile('img')){
$file = $request->file('img');
$name = $file->getClientOriginalName();
$path = public_path() .'\img\controles';
$file->move($path,$name);
}
dd($path) = /home/onelap/login/public/img/controles
then the problem is generated in the '$ path', I can not get it to point to public_html / img / controls. PS: I tried with the method '$ request-> file (' img ') -> store (' public ')' but it only works on localhost and not on the server.