将 csv 从远程 sftp 服务器复制到我的服务器的 WordPress 目录
我正在寻找一种解决方案,如何复制远程 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论