I recently hosted my first Laravel project. This therefore means that the public folder is on public_html while the others are on one forder in the root.
I was uploading a file to the server and got the error Could not create img/photos directory (paraphrase). I googled for quite some time and after that i gave 777 permission to img and photos and the error disappeared. The only thing is that now there is no error being caught but the file is just not being uploaded.
NOTE: In my form declaration i have set 'files'=>true, i have properly modified my autoload and paths.php paths.
// controller
// upload cover photo if any
$path = public_path().'/img/album-cover-photos';
if(Input::hasFile('photo'))
{
$ext = Input::file('photo')->getClientOriginalExtension();
$name = "Album-Cover-".$album->id.'-'.date('YmdHis').'.'.$ext;
Input::file('photo')->move($path,$name);
$album->cover_photo = $name;
$album->save();
}
What could the issue be?
Let me answer this. I got where the problem was. Even if i insisted in the question that I had set
paths.phppaths correctly, that was exactly where the problem was.publicpath had been set as__DIR__.'/../public_html/mylaravelpublicinstead of__DIR__.'/../../public_html/mylaravelpublic. I really hope that this helps somebody.Just to say, im on shared hosting so my laravel public folder contents are put in a
public_htmlsubfolder as above, and not inpublic_htmlitself.If you are not on shared hosting, i think your path should just end atpublic_htmlwithout any subfolder.