Signature Pad

Posted 2 years ago by theUnforgiven

I'm using this package - https://github.com/szimek/signature_pad

Which allows drawing on screen for signatures etc, it all works, but the file_put_contents() is placing the file in the public directory. But I don't want this I want store it in public/uploads/signatures for example.

$data_uri = $request->signature;
        $encoded_image = explode(",", $data_uri)[1];
        $decoded_image = base64_decode($encoded_image);

        $contents = file_put_contents(sha1($request->session()->get('user.first_name').$request->session()->get('user.last_name')) . "_signature.png", $decoded_image);

The above is what I have currently which obviously return a base64 png file/image but I want to move to the public/uploads/signatures directory then remove from the public directory so I don't have duplicates.

How can one achieve this? I have tried the rename() & move_uploaded_file() functions to no avail.

Please sign in or create an account to participate in this conversation.