File size: 1,073 Bytes
a4a352b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
namespace app\common\extend\upload;

use app\common\util\Ftp as ftpOper;

class Ftp
{
    public $name = 'FTP存储';
    public $ver = '1.0';
    private $config = [];

    public function __construct($config = []) {
        $this->config = $config;
    }

    public function submit($file_path)
    {
        $ftp = new ftpOper();
        $ftp_config = [
            'ftp_host'=>$GLOBALS['config']['upload']['api']['ftp']['host'],
            'ftp_port'=>$GLOBALS['config']['upload']['api']['ftp']['port'],
            'ftp_user'=>$GLOBALS['config']['upload']['api']['ftp']['user'],
            'ftp_pwd' =>$GLOBALS['config']['upload']['api']['ftp']['pwd'],
            'ftp_dir'=>$GLOBALS['config']['upload']['api']['ftp']['path'],
        ];
        $ftp->config($ftp_config);
        $ftp->connect();
        $a = $ftp->put(ROOT_PATH. $file_path, $file_path);
        $filePath = ROOT_PATH . $file_path;
        empty($this->config['keep_local']) && @unlink($filePath);
        return $GLOBALS['config']['upload']['api']['ftp']['url'] . '/' . $file_path;
    }
}