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 即可。