Javascript 我没有许可

Javascript 我没有许可,javascript,php,ajax,laravel,xampp,Javascript,Php,Ajax,Laravel,Xampp,我正在使用laravel web应用程序将图像上传到datatable中,并在单击时下载该图像。它工作正常(但我希望上传的图像在单击时下载),直到我将代码从return'{!!Html::link('images/u4.png','download')!!};更改为return'{!!Html::link('images/$doc->image','download')!!}“;我得到了这个错误 我正在使用xampp localhost 我的代码让你了解我的处境 index.blade.php

我正在使用laravel web应用程序将图像上传到datatable中,并在单击时下载该图像。它工作正常(但我希望上传的图像在单击时下载),直到我将代码从
return'{!!Html::link('images/u4.png','download')!!};
更改为
return'{!!Html::link('images/$doc->image','download')!!}“;
我得到了这个错误 我正在使用xampp localhost 我的代码让你了解我的处境 index.blade.php

 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="/images/.$doc->image" download >Download</a>' 
                 return '{!! Html::link('images/.$doc->image', 'Download') !!}';
                 //  return '{!! Html::link('images/u4.png', 'Download') !!}';
             } }, 
            
            //'image' => ['name' => 'image', 'data' => 'image'],                                   
            { data: 'comments', name: 'comments' },            
            { data: 'action', orderable: false, searchable: false}        
        ],
//此代码是在存储方法中编写的

$this->validate$请求[

    'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:6048',
]);
$doc = new Document($request->input()) ;

if($file = $request->hasFile('image')) {
   
   $file = $request->file('image') ;
   
   $fileName = $file->getClientOriginalName() ;
   $destinationPath = public_path().'/images/' ;
   $file->move($destinationPath,$fileName);
   $doc->image = $fileName ;
}

路线


您生成了错误的路由。在屏幕截图中,您攻击的浏览器上的URL是
localhost/conta/public/images/$doc->image
,这不是有效的路由,这就是apache抛出“禁止错误”的原因


生成一个有效的url可能会解决您的问题。

s如何编写正确的路径请帮助,因为我对此非常陌生。我已删除$doc->image,然后它会将我导航到images文件夹并显示图像列表
    'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:6048',
]);
$doc = new Document($request->input()) ;

if($file = $request->hasFile('image')) {
   
   $file = $request->file('image') ;
   
   $fileName = $file->getClientOriginalName() ;
   $destinationPath = public_path().'/images/' ;
   $file->move($destinationPath,$fileName);
   $doc->image = $fileName ;
Route::get('/images/{file}','DocumentsController@download');