LARAVEL PROBLEM IMAGE NOT UPLOAD PROBLEM (THE SAME PROBLEM WORKED IN LOCALHOST)

Problem Description:

I have recently created a site in laravel and I had the no issue. But when I uploaded the script in the live server, there was an issue in uploading images.

My form was absolutely fine

<form action="{{route('subject.store')}}" method="POST" enctype="multipart/form-data">

{{csrf_field()}}

<input type="file" name="image">
<button type="submit"> Submit </button>
</form>

My controller was absolutely Ok

public function store(Request $request)
{

$post=new Note;

/*image*/
$image=$request->file('image');

$new_name=date('y_m_d_h_i_s').'.'.$image->getClientOriginalExtension();
$image->move(public_path('images/posts/'),$new_name);
$post->feature_image=$new_name;
}

$post->save();

}

 

Same code worked in the localhost and live server got the problem. Others were OK.

[SOLUTION]

the solution was simple in the live server I added this code to my public_html/index.php file after declaring $app and it’s working now.

// set the public path to this directory
$app->bind('path.public', function() {
return __DIR__;
});