繁体   English   中英

PHP/Laravel - 将图像(PNG)从 base64 保存到 FTP 服务器而不在本地保存

[英]PHP/Laravel - Saving an image(PNG) from a base64 to an FTP Server without saving it locally

我正在使用 laravel 来获取发布请求 base64。 然后在 controller 上,我想将 base64 解码为 png 文件,然后立即将文件存储到 FTP 存储而不保存到我的本地文件夹。 这是我的Controller

 $path     = "test/image.png";
 $image    = explode(',',$imgbg);
 $base64   = $image[1];
 $result   = base64_decode($base64);

 file_put_contents("ori.png", $result);

 Storage::disk('ftp-dev')->put($path, file_get_contents("ori.png"));

截至目前,它将文件保存在本地,然后获取文件内容以将其保存到 FTP 服务器。 有没有办法做到这一点,它不会在本地保存文件,而只是将它保存在 FTP 服务器中? 欢迎和赞赏任何建议。

我的解决方案是:

Storage::disk('ftp-dev')->put($path, $result);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM