Lravel 5.5 ftp 文件上传出错

150 篇文章 5 订阅
4 篇文章 0 订阅

hello ,when iuse laravel 5.5 ,and save file to my ftp server ,it cannot connect to it ,but when i use plain php code ,it can connect and upload file .
my laravel code :

$path = $request->file('file')->storeAs($save_path . '/' . date('Y-m'), $save_name, 'ftp');

my filesystems.php is like this :

'ftp' => [
    'driver' => 'ftp',
    'host' => '52.xxx.127.239',
    'username' => 'xxx',
    'password' => 'xxx',
    'root' => '/xxx/xx/data',
    'passive' => true,
    'timeout' => 300,
],

my plain code like below :

$ftpserver = '52.xx.xxx.239';
$login = 'xxx';
$pass = 'xxx';

$conn_id = ftp_connect($ftpserver);
ftp_login($conn_id, $login, $pass);
$file = app_path('Http/Controllers/HomeController.php');
$new_file = 'bbb.txt'; //新的文件名
$ret = ftp_nb_put($conn_id, $new_file, $file, FTP_BINARY);
while ($ret == FTP_MOREDATA) {
    // 任何其他需要做的操作
    echo ".==================";
    // 继续上传...
    $ret = ftp_nb_continue($conn_id);
}
if ($ret != FTP_FINISHED) {
    echo "There was an error uploading the file...";
    exit(1);
}
ftp_close($conn_id);

what’s wrong ?
thank you !

记录一下,这是在用laravel ftp上传文件的时候报错了,目前还未解决。

sf上的问题链接,那个提问的很不人性化,搞半天才提个问题,不晓得有没有人回答。
https://stackoverflow.com/users/7819816/shuiping-yang

解决了,’passive’ => true,改为false 即可。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

SHUIPING_YANG

你的鼓励是我创作的最大动力。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值