mardi 30 octobre 2018

How to add row id of current user in upload

I'm working in laravel PHP in dx grid dev extreme and I'm having problem while uploading imgae. as image is saved in server but now i want to add image in db by getting users id while row is clicked... how ever I need to update the image in db and frontend as well..enter image description here

`

public function uploadImg(Request $request){

if($request['fileInput']){ 


    $fileName = time().'_'.basename($_FILES["fileInput"]["name"]);
    // dd($fileName);
   $targetDir = "storage/users/";
    $targetFilePath = $targetDir . $fileName;
      // dd($_FILES["fileInput"]["tmp_name"]);
    $fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION);
    $allowTypes = array('jpg','png','jpeg','gif');

    if(in_array($fileType, $allowTypes)){
       if(move_uploaded_file($_FILES["fileInput"]["tmp_name"], $targetFilePath)){
// dd($targetFilePath);
            return redirect()->back();
        }else{
            $response['status'] = 'err';
        }
    }else{
        $response['status'] = 'type_err';
    }
    echo json_encode($response);
}

}

`

dataField: "avatar",
            caption: "Add Image",
            width: 200,
            alignment: 'center',
            formItem: {
                    visible: false
                },
            width: 100,
            alignment: 'center',
            type:"button",
            cellTemplate: function (container, options) {
                $("<div />")
                    .text('Upload')
                    .on('dxclick', function () {
                        // alert('ok');

                        $('#fileInput').trigger('click',function(){
                            id: "users->id",

                           $("#imageform").onValueChanged(function(){

                       // uploadUrl: ""
                              $("#form").submit();
                            })

                        });

                    })
                    .appendTo(container);

            }
        },



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire