我试图从存储文件夹中预加载图像到dropzone中。这是我有:Laravel 5.2不允许加载本地资源:从存储文件夹
AJAX
$.ajax({
url: "suspect_images",
data: { id: $('input[name=b_id]').val(), _token: $('input[name=_token]').val()},
dataType: 'json',
type: 'GET',
success: function (data) {
$.each(data.images, function (key, value) {
var file = {name: value.original, size: value.size};
dropZone.options.addedfile.call(dropZone, file);
dropZone.options.thumbnail.call(dropZone, file, value.path + value.server);
dropZone.emit("complete", file);
dropZone.files.push(file);
});
},
error: function (data) {
}
}, "json")
控制器
$images = Mugshots::select("AccusedID", "FileName", "OriginalFileName")->where("AccusedID", "=", $request->input('id'))->get();
$imageAnswer = [];
foreach ($images as $image) {
$imageAnswer[] = [
'original' => $image->OriginalFileName,
'server' => $image->FileName,
'size' => File::size(storage_path() . '/uploads/images/suspects/' . $request->input('id') . '/full_size/' . $image->FileName),
'path' => storage_path() . '/uploads/images/suspects/' . $request->input('id') . '/full_size/'
];
}
return response()->json([
'images' => $imageAnswer
]);
这将返回
Not allowed to load local resource: file:///C:/xampp/htdocs/IMS/storage/uploads/images/suspects/2/full_size/file.jpg
现在,这可能会工作,如果我的图片是在公共文件夹中。但出于安全原因,我必须将其存储在存储文件夹中。我能够通过浏览器访问该文件,当我粘贴的网址,但不是在JavaScript中。我认为这可能是因为权限。我怎样才能从存储文件夹加载文件并将其显示在dropzone上?
我在询问关于将它加载到dropzone而不是图像标记。
可能的重复[不允许使用Laravel加载本地资源](http://stackoverflow.com/questions/37415159/not-allowed-to-load-local-resource-with-laravel) – hassan
@hassan I' m询问dropzone不只是将它加载到图像标签中。 –
这是我认为的同样的问题,您的浏览器试图从硬盘加载资源,对于您可能需要从tmp目录加载图像的dropzone。 – hassan