Laravel - 将上载的文件URL添加到AJAX模式

如果我通过get请求通过AJAX提取数据,我很好奇如何获取文件的完整URL .

目前,我成功提取的数据包括以下内容:

$('#attachmentIDdetails').html(
    '<strong>'+data.attachmentTitle+'</strong><br>Description: '+data.attachmentBody+'<br>Date '+data.attachmentDate +'<br>Type: '+data.attachmentType +'<br>Visibility: '+data.attachmentVisibility + '<br>Uploaded by: '+data.user_id+'<br><a href="'+data.attachmentPath+'">Download Attachment</a><br><img width="100%" src="https://maps.googleapis.com/maps/api/staticmap?center='+data.attachmentLat+',+'+data.attachmentLong+'&zoom=13&scale=1&size=600x300&maptype=roadmap&key=MYSECRETKEY&format=png&visual_refresh=true&markers=size:mid%7Ccolor:0xff0000%7Clabel:%7C'+data.attachmentLat+',+'+data.attachmentLong+'" alt="Google Map of '+data.attachmentLat+',+'+data.attachmentLong+'">' );
}

如果你看,一个功能是我的:data.attachmentPath - 这只是文件名 . 它位于存储文件夹下的 Headers 为“货件”的文件夹中 . 那么我该如何提取下载链接的完整URL?

这是ajax调用请求的控制器代码:

public function attachmentDetails(Request $request)
{
    return Shipment_Attachment::findOrFail($request->attachmentID); 
}

回答(0)