davy_yg's avatar
Level 27

upload file with pop up

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 action="{{ action('SettingController@UploadBackgroundProfile') }}" method="post">
        <div class="modal-body">                        
            <input type="file" name="b_pic">
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            <button type="button" class="btn btn-primary">Upload Image</button> 
        </div>
        </form>
    </div>
    <!-- /.modal-content -->
 </div>
 <!-- /.modal-dialog -->
</div>

Controllers/SettingController.php

public function UploadBackgroundProfile(Request $request)
{

    $b_pic = $request->file('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');
}

Hello,

on press upload image I am hoping that the selected image being copy to the selected folder. But it does not, I wonder why? Infact, nothing happen!

0 likes
0 replies

Please or to participate in this conversation.