0

Hello,

This is laravel. I wonder why after pressing, Upload Image button nothing happen. I doubt that it even pass the controller. Any clue?

setting.blade.php

<div id="myModal" class="modal fade">
<div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
             <h4 class="modal-title">Please input a new background</h4>
        </div>

        <form method="post" enctype="multipart/form-data" action="{{ URL::to('/home/upbprofile') }}">
        <input type="hidden" name="_token" id="_token" value="<?php echo csrf_token() ?>">

        <div class="modal-body">                            
            <input type="file" name="b_pic">
        </div>
        <div class="modal-footer">
            <input type="submit" value="Upload Image" class="btn btn-primary" data-dismiss="modal">
        </div> 
        </form>
    </div>
    <!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>

routes.php

 Route::post('/home/upbprofile', 'SettingController@UploadBackgroundProfile');

SettingController.php

public function UploadBackgroundProfile(Request $request)
{

    $b_pic = $request->file('b_pic');

    dd($b_pic);

    if($b_pic != NULL)
        $b_pic->move('uploads/bgprofile', $b_pic->getClientOriginalName());

    if($b_pic != NULL)
    {   
        // simpan yg baru
        $model->bgprofile = $b_pic->getClientOriginalName();
    }

    $model->save();

    return view('soulfy.setting');
}     
2
Contributors
3
Replies
19
Views
2 Weeks
Discussion Span
Last Post by diafol
0

Here I update my controller:

Still nothing happen when I press Upload Image.

SettingController.php

public function UploadBackgroundProfile(Request $request)
{

    $b_pic = $request->file('b_pic');

    $id = $request->input('id');

    $model = UserbgProfile::find($id);

    if($b_pic != NULL)
        $b_pic->move('uploads/bgprofile', $b_pic->getClientOriginalName());

    if($b_pic != NULL)
    {   
        // simpan yg baru
        $model->bgprofile = $b_pic->getClientOriginalName();
    }

    $model->save();

    return view('soulfy.setting');
}

UserbgProfile.php

 <?php

 namespace Soulfy;

 use Illuminate\Database\Eloquent\Model;

 class UserbgProfile extends Model
{
//
protected $table = "user_bgprofile";
}

Edited by davy_yg

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.