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

时间:2017-12-06 19:09:44

标签: php jquery ajax laravel laravel-5

如果我通过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 - 这只是文件名。它位于存储文件夹下的标题为“货件”的文件夹中。那么我将如何提取下载链接的完整URL?

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

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

0 个答案:

没有答案