Laravel

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__;
});

 

jaminrai

Share
Published by
jaminrai

Recent Posts

Skype Closes Its Doors After 20 Years: A Look Back and the Apps That Faded with It

After 20 years of transforming global communication, Skype has officially ceased operations. Microsoft, which purchased…

2 months ago

The Duck and the Tortoise: A Tale of Patience and Teamwork

In a serene forest by the edge of a sparkling lake, there lived a cheerful…

3 months ago

10 Smart Strategies for a Secure and Enjoyable Retirement

Retiring comfortably is a goal many aspire to achieve, and with the right strategies, it’s…

3 months ago

Troubleshooting a Slow Computer

Is your computer running frustratingly slow? Don't worry; you're not alone in facing this common…

3 months ago

The Clever Fox and the Greedy Crow

Once, in a sunny forest, Fox and Crow were friends. One day, Crow found a…

3 months ago