php - 如何使用文件系统将文件从本地移动到 Laraver 中的 sftp 文件夹?
问题描述
我想使用 sftp 将文件从本地移动到另一台服务器,这是我在 config/filesystem.php 中的 sftp 设置
'sftp' => [
'driver' => 'sftp',
'host' => '192.xxx.0.xxx',
'port' => 22,
'username' => 'xxx',
'password' => 'xxx',
'root' => '/',
'timeout' => 10,
],
这是我在控制器中的代码
$file_local = public_path().'/documents/1.pdf';
$file_sftp = Storage::disk('sftp')->put('1.pdf', $file_local);
$move = File::move($file_local, $file_ftp);
解决方案
777许可!是邪恶的关键入口!我不会那样配置我的应用程序!我会先检查该文件是否仍然存在于存储文件夹中(您正在重命名的文件)。我的第二个假设 - 该文件由完全不同的用户拥有?通常整个项目应该在一个 user.group 所有者之下!在您的情况下可能是 apache.groupName 但您应该仔细检查。所以我会做
ls -la // in project root directory and grab the ownerUser and ownerGroup names
// then I ld make sure everything is owned by them - back up your project first before changing ownership!
sudo chown -R ownerUser.ownerGroup * // -R for recursive
如果没有,我会将其保存在存储文件夹以外的其他位置。希望这对你有帮助
推荐阅读
- c# - 大写对象列表c#
- javascript - 如何通过 LibGDX 使用 Facebook Instant Games 排行榜和应用内广告
- android - 我的应用程序遇到此错误无法安装应用程序安装失败
- javascript - 如何在使用地图的反应中将json转换为csv
- android - 即使在基于紧急系统的应用程序的打盹和应用程序待机模式下也需要推送通知支持
- angular - 我无法使用 ```http.post``` 发送数据
- flutter - cubit 的静态返回值不会发出新的状态
- javascript - 一次性下载所有 Google 表格图表?
- javascript - 如何从 django 视图中的 HTML 用户输入中获取价值?
- google-assistant-sdk - Google 智能助理 - 一直要求打开个人搜索结果,即使它已打开