Categories: 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

Computer Science Project Report Guidelines and Sample

Guidelines (Click Below to Download) SAMPLE 1 SAMPLE 2

5 months ago

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…

12 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…

1 year ago