Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Arif998's avatar

jQuery Signature for mobile

Hello, experts why its not working for mobile ? what should i need to include to solve this problem

 <form method="POST" action="{{ route('signaturepad.upload') }}">
                            @csrf
                            <div class="col-md-12">
                                <input type="hidden" name="id" value="{{ $token }}">
                                <label class="" for="">Signature:</label>
                                <div id="sig"></div>
                                <button id="clear" class="btn btn-danger btn-sm">Clear Signature</button>
                                <textarea id="signature64" name="signed" style="display: none"></textarea>
                            </div>
                            <button class="btn btn-success">Save</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        var sig = $('#sig').signature({
            syncField: '#signature64',
            syncFormat: 'PNG'
        });
        $('#clear').click(function(e) {
            e.preventDefault();
            sig.signature('clear');
            $("#signature64").val('');
        });
    </script>

And my controller

        $folderPath = public_path('upload/');
        $image_parts = explode(";base64,", $request->signed);
        $image_type_aux = explode("image/", $image_parts[0]);
        $image_type = $image_type_aux[1];
        $image_base64 = base64_decode($image_parts[1]);
        $file = $folderPath .$request->id. '.'.$image_type;
        file_put_contents($file, $image_base64);
        // return back()->with('success', 'success Full upload signature');
        return redirect('generate-pdf/'.$request->id);
0 likes
0 replies

Please or to participate in this conversation.