patibra's avatar

problem saving image to database online

Hi, i ma using laravel Intervention Image to save images as following

$post = new post;

    if ($request->hasFile('image')) {
        
        $image = $request->file('image');
        $file_name = time().'-brokafasi.'.$image->getClientOriginalExtension();
        $location = public_path('user/images/'.$file_name);

        Image::make($image)->resize(500,333)->save($location);
        $post -> image = $file_name;

    }

this code working properly in local but once i upload the project on shared server (hostgator) i am getting 500 error whenever i upload a post with image. but if i try to upload the same post without image, i am not getting any error and the post is posted correctly.

any one have an idea on this kind of error? help please...

0 likes
4 replies
tykus's avatar

Is the public path writable by the www user on the production server?

patibra's avatar
patibra
OP
Best Answer
Level 1

issue solved, path problem...

i had just to add /../ in front of the path here:

$location = public_path('/../user/images/'.$file_name);

Please or to participate in this conversation.