• 05-03-2021, 11:29:13
    #1
    data table ile istek listesindeki ürünleri excele çıkarmayı yaptım ama bunların yanında isteğe bağlı olarak fotoğraflı şekilde de liste yapıp indirmesini istiyorum aşağıda yazdığım kodu buldum ama 6. satırında base64 kısmında "Uncaught SyntaxError: Unexpected string" hatası alıyorum yardımcı olabilecek arkadaşlar var mı


    jQuery(document).ready(function ($) {
    $image = 'https://www.hurpaz.com/wp-content/uploads/2021/01/BG1419301-1-300x300.jpg';
    $type = pathinfo($image, PATHINFO_EXTENSION);
    $data = file_get_contents($image);
    $imgData = base64_encode($data);
    $src = 'data:image/' . $type . ';base64,' . $imgData;
     
         $(document).ready(function() {
        $('#example').DataTable( {
            dom: 'Bfrtip',
            buttons: [
                {
                    extend: 'copyHtml5',
                    text :'Copy',
                    exportOptions: {
                        columns: [ 2,3,4 ]
                    }
                },
                {
                    extend: 'excelHtml5',
                    text :'Excel',
                    exportOptions: {
                        columns: [ 2,3,4 ]
                    }
                },
                  {
                extend: 'pdfHtml5',
                orientation: 'landscape',
                customize: function (doc) {
                   if (doc) {
                        for (var i = 1; i < doc.content[1].table.body.length; i++) {
                            doc.content[1].table.body[i][1] = {
                                image: '<?php echo $src; ?>,
                            };
                        }
                    }
                },
                exportOptions: {
                    stripHtml: false
            },
            }
                {
                    extend:'pageLength',
                    text :'Adet',
                    lengthMenu: [
                        [ 10, 25, 50, 1 ],
                        [ '10 rows', '25 rows', '50 rows', 'Show all' ]
                    ],
    
                },
            ]
        } );
    } );
    });
  • 05-03-2021, 11:44:26
    #2
    Üyeliği durduruldu
    JS kodunun içinde PHP kodu kullanmışsınız, bu şekilde olmaması lazım.

    jQuery(document).ready(function ($) {
    $image = 'https://www.hurpaz.com/wp-content/uploads/2021/01/BG1419301-1-300x300.jpg';
    $type = pathinfo($image, PATHINFO_EXTENSION);
    $data = file_get_contents($image);
    $imgData = base64_encode($data);
    $src = 'data:image/' . $type . ';base64,' . $imgData;

    kısmını

    jQuery(document).ready(function ($) {
    <?php
    $image = 'https://www.hurpaz.com/wp-content/uploads/2021/01/BG1419301-1-300x300.jpg';
    $type = pathinfo($image, PATHINFO_EXTENSION);
    $data = file_get_contents($image);
    $imgData = base64_encode($data);
    $src = 'data:image/' . $type . ';base64,' . $imgData;
    ?>

    olarak değiştirip deneyin.