我试图使用“保存到云端硬盘”按钮,谷歌提供了使驱动器上传更加容易,它看起来像这样:Google Drive与Laravel保存在一起吗?
<script src="https://apis.google.com/js/platform.js" async defer></script>
<div class="g-savetodrive"
data-src="//example.com/path/to/myfile.pdf"
data-filename="My Statement.pdf"
data-sitename="My Company Name">
</div>
我的问题是,因为我使用Laravel和php artisan serve
命令为我的项目服务,我该怎么写我的文件的路径?它位于'Project name'/ storage/app/docs /中,我试过//storage/app/docs/{{ $file->path }}
,但它不起作用,并且使用storage_path()并没有改变任何东西。我在这里错过了什么?
编辑: 我尝试使用另一个文件,其中一个托管在别处。所以我启用CORS在我的项目,并使用邮差,我测试看标题我用的是:
Access-Control-Allow-Headers →Content-Type, X-Auth-Token, Origin, Range
Access-Control-Allow-Methods →POST, GET, OPTIONS, PUT, DELETE
Access-Control-Allow-Origin →*
Access-Control-Expose-Headers →Cache-Control, Content-Encoding, Content-Range
按照谷歌文档,应该现在的工作,但事实并非如此。 这是我收到的控制台错误:
Response to preflight request doesn't pass access control check:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://localhost:8000' is therefore not allowed access.
The response had HTTP status code 400.
而且我oficially的想法。
''//在'//例子。 com/.....“仅仅是”现在正在使用的任何协议“的简称。请参阅[此问题](http://stackoverflow.com/a/9646435/605707)了解更多信息。 – deefour
我现在明白了,但我仍然使用Laravel的'asset()'函数(它应该自动解析请求方案)并且它仍然不起作用,我只是得到一个“失败的下载XHR错误” –
无论asset()'的行为如何,你不能指向HTML根目录之外的文件。浏览器只能在您的Laravel应用的公共/文件夹中发送请求。阅读** Public Disk部分[在这些文档](https://laravel.com/docs/5.3/filesystem#configuration)以了解更多关于'storage/app/docs /'目录应该如何符号链接到'public /'。 – deefour