如何将ftp文件拉到本地项目中
有个需求就是将ftp文件下载到服务器项目中。先贴代码
$coupontxt1 = 'data_2021-10-02.csv';//ftp文件名
$save_path = storage_path('app/upv/').'data_2021-10-01.csv';
//$coupontxt1 = storage_path('app/upv/').'data_2021-10-11.csv';
$res = Storage::disk('ftp_upv')->download($coupontxt1,$save_path);
return $res;
用download直接就是下载到本地了,没有办法指定路径,写上路径就报错了
The filename and the fallback cannot contain the "/" and "\" characters
考虑了改root
依然是空,而且改了root下载下来的东西是个路径,不是文件
然后我就用了put
$coupontxt1 = 'data_2021-10-02.csv';//ftp文件名
$save_path = storage_path('app/upv');
//$coupontxt1 = storage_path('app/upv/').'data_2021-10-11.csv';
$res = Storage::disk('ftp_upv')->put($coupontxt1,$save_path.'/'.$coupontxt1);
dd($res);
打印出来是true,但是项目文件下还是空空如也
这个该怎么弄呢(不考虑用其他扩展)
话说好久没发问题了,为什么我没有问答的选项
先下载ftp文件到项目,找个ftp包下载文件
怎么不能指定路径,filesystems.php 中
disk
你的ftp_upv
中修改root
我们是直接shell下载
realpath('./')把相对路径改成绝对路径试试。