0

I am new to javascript and jquery and want to download image from datatable column where i have saved my image in public/images folder of laravel framework but when i click on download link some random files downloads which failed to download. here is my code and screenshot of what i am actually trying to do

  columns: [
            // render:function(data,type,full,meta){
            //     return '<a href="'+data.filepath+'/'+data.fileName + '" download>Download</a>' 
            // },
            // "targets": 0
          // { data: 'rownum', orderable: false, searchable: false },
            { data: 'doc_type', name: 'doc_type' },                                              
            { data: 'doc_number', name: 'doc_number' },
            { data: 'doc_date', name: 'doc_date'},                                              
            { data: 'amount', name: 'amount' },  
                                                        
            { data: 'currency', name: 'currency' },                                              
            { data: 'partener', name: '{{ TBL_PARTENER }}.id'}, 
            { data: 'image', name: 'image',render:function(data,type,full,meta){
                // return '<a href="'+data.filepath+'/'+data.fileName + '" download="myImage">Download</a>' 
                 return '<a href="data:/images/u4.png" download="">Download</a>' 
             } }, 
            
            //'image' => ['name' => 'image', 'data' => 'image'],                                   
            { data: 'comments', name: 'comments' },            
            { data: 'action', orderable: false, searchable: false}        
        ],

Please view this screenshot of output Much appreaciated your help

Ayaz Khan
  • 1
  • 3

1 Answers1

0

I cann't comment so i write here! What happens if you remove "data:"?

Minh Viet
  • 61
  • 1
  • 5