ppypp伦理天堂,91手机在线视频,免费在线观看黄色毛片,夜夜穞天天穞狠狠穞AV美女按摩

聯系官方銷售客服

1835022288

028-61286886

投訴 分享 遠程附件FTP的存儲老是失敗 8 0
鄧振波 免費會員 2020-07-01 15:35:10 私信
迅睿CMS版本:4.3.8

www.zbshanke.com的遠程附件FTP的存儲老是失敗,我修改了一下,終于成功了。對應dayrui\ThirdParty\Storage\Ftp.php文件

<?php namespace Phpcmf\ThirdParty\Storage;

// Ftp文件存儲

class Ftp {

// 存儲內容

protected $data;

// 文件存儲路徑

protected $filename;

// 文件存儲目錄

protected $filepath;

// 附件存儲的信息

protected $attachment;

// 是否進行圖片水印

protected $watermark;

// 完整的文件目錄

protected $fullpath;

// 完整的文件路徑

protected $fullname;

// 初始化參數

public function init($attachment, $filename) {

$this->filename = trim($filename, DIRECTORY_SEPARATOR);

$this->filepath = dirname($filename);

$this->filepath == '.' && $this->filepath = '';

$attachment['value']['path'] = rtrim($attachment['value']['path'], DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;

$this->attachment = $attachment;

$this->fullpath = $this->attachment['value']['path'].$this->filepath;

$this->fullname = $this->attachment['value']['path'].$this->filename;

return $this;

}

public function makeDir($connect, $dirPath){

//處理目錄

$dirPath = '/' . trim($dirPath, '/');

$dirPath = explode('/', $dirPath);

foreach ($dirPath as $dir) {

if ($dir == '') $dir = '/';

//判斷目錄是否存在

if (@ftp_chdir($connect, $dir) == false) {

//判斷目錄是否創建成功

if (@ftp_mkDir($connect, $dir) == false) {

return 2;

}

@ftp_chdir($connect, $dir);

}

}

return true;

}

// 文件上傳模式

public function upload($type = 0, $data, $watermark) {

$this->data = $data;

$this->watermark = $watermark;

if (!function_exists('ftp_connect')) {

return dr_return_data(0, dr_lang('PHP環境不支持FTP函數'));

}

// ftp同步

if (FALSE === ($conn_id = @ftp_connect($this->attachment['value']['host'], $this->attachment['value']['port']))) {

return dr_return_data(0, dr_lang('FTP服務器連接失敗'));

}

if (@ftp_login($conn_id, $this->attachment['value']['username'], $this->attachment['value']['password']) === FALSE) {

return dr_return_data(0, dr_lang('FTP服務器賬號認證失敗'));

}

$this->attachment['value']['pasv'] && @ftp_pasv($conn_id, TRUE);

//@ftp_mkdir($conn_id, $this->fullpath);

//@ftp_chmod($conn_id, '0775', $this->fullpath);

if(!$this->makeDir($conn_id, dirname($this->fullname))){

return dr_return_data(0, dr_lang('無法創建FTP目錄'));

}

// 本地臨時文件

$locpath = WRITEPATH.'attach/'.md5($this->fullname);

// 存儲文件 移動上傳或者內容存儲

if ($type) {

// 移動失敗

if (!(move_uploaded_file($this->data, $locpath) || !is_file($locpath))) {

return dr_return_data(0, dr_lang('文件移動失敗'));

}

} else {

$filesize = file_put_contents($locpath, $this->data);

if (!$filesize || !is_file($locpath)) {

return dr_return_data(0, dr_lang('文件創建失敗'));

}

}

if (FALSE === ($result = @ftp_put($conn_id, basename($this->fullname), $locpath, ($this->attachment['value']['mode'] === 'ascii') ? FTP_ASCII : FTP_BINARY))) {

@unlink($locpath);

return dr_return_data(0, dr_lang('FTP服務器上傳失敗'));

}

@ftp_close($conn_id);

// 強制水印

if ($this->watermark) {

$config = \Phpcmf\Service::C()->get_cache('site', SITE_ID, 'watermark');

$config['source_image'] = $locpath;

$config['dynamic_output'] = false;

\Phpcmf\Service::L('Image')->watermark($config);

}

$md5 = md5_file($locpath);

@unlink($locpath);

// 上傳成功

return dr_return_data(1, 'ok', [

'url' => $this->attachment['url'].$this->filename,

'md5' => $md5,

]);

}

// 刪除文件 這個我目前不會寫

public function delete() {

@unlink($this->fullname);

//log_message('info', 'CSRF token verified');

}

}

解決方案