将 csv 从远程 sftp 服务器复制到我的服务器的 WordPress 目录

发布于 2025-01-15 05:40:22 字数 709 浏览 3 评论 0原文

我正在寻找一种解决方案,如何复制远程 sftp 服务器上的 csv 文件并使其在我的服务器上可用。然后,我使用一个插件将该 csv 中的数据提取到我的 WordPress 数据库中。

我尝试用这个 PHP 脚本来做到这一点: https://phpseclib.com/docs/sftp

我需要在我的服务器上安装一些东西才能获得这跑?抱歉,但我不是很后端,而且有点菜鸟。可能有一种更简单的方法可以解决此问题。

当我在浏览器中运行此 PHP 文件时,出现 500 错误。

<?php
function getData(){
    use phpseclib3\Net\SFTP;

    $sftp = new SFTP('server-domain', port); //default port is 22

    if (!$sftp->login('username', 'password')) {
        throw new Exception('Login failed');
    }

    $sftp->get(‘remote-server-file.csv’, 'my-server-file.csv' ); // return content of the file
    getData();
?>

I'm looking for a solution to how I can copy a csv file that is on a remote sftp server and have it available on my server. I'm then using a plugin to pull the data from this csv into my wordpress database.

I have tried to do this with this PHP script:
https://phpseclib.com/docs/sftp

Do I need to install something on my server to get this running? Sorry, but I'm not very backend and a bit of a noob. There's probably a way easier approach to this..

I get a 500 error when I run this PHP file in the browser.

<?php
function getData(){
    use phpseclib3\Net\SFTP;

    $sftp = new SFTP('server-domain', port); //default port is 22

    if (!$sftp->login('username', 'password')) {
        throw new Exception('Login failed');
    }

    $sftp->get(‘remote-server-file.csv’, 'my-server-file.csv' ); // return content of the file
    getData();
?>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文