【发布时间】:2020-02-17 09:24:16
【问题描述】:
我正在将图像文件保存到磁盘。之后,我创建一个 ZIP 并下载它。在 localhost 上一切正常。
在我得到的实时服务器上:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at webmaster@example.com to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
如果我想将图像保存到存储中,则会发生错误:
$user = DB::connection('mysql_live')->table('users')->where('id', $userid)->first();
Storage::disk('gdpr')->put($user->picture, file_get_contents(env('AVATAR_PHOTO_SRC') . $user->picture));
env('AVATAR_PHOTO_SRC')是图片的绝对路径,例如:https://example.com/uploads/thumb/
没有创建日志文件。而且压缩包的大小不到 1MB,图片更小。
这里发生了什么?
编辑
$user->picture 是文件名。例如:example.jpg。
该文件确实存在并且可以在浏览器中打开。请记住,在 localhost 上一切正常。
编辑
我找到了一个登录try,catch:
file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0
编辑
无法在共享服务器上修改 PHP 初始化。我需要另一种方法来存储图像。
【问题讨论】:
-
什么是
$user->picture?是路径吗?env('AVATAR_PHOTO_SRC') . $user->picture)上是否真的存在图像?您可能还想尝试/捕获 put 语句。 -
@QumberRizvi 请查看我的编辑
-
@QumberRizvi 我用 try catch 找到了一些东西,请参阅我的更新。看来我不能以这种方式存储图像,因为我无法更改服务器配置。
-
请编辑您的 php.ini 以允许 url_fopen:
allow_url_fopen = 1 allow_url_include = 1
标签: php laravel image download storage