先通过composer安装SabreDAV库:
composer require sabre/dav ~3.2
新建一个server.php文件:
<?php
require 'vendor/autoload.php';
$publicDir = './'; // 你想要作为WebDAV的目录
// 设置用户名和密码
$authBackend = new Sabre\DAV\Auth\Backend\File('./.htdigest');
$authBackend->setRealm('SabreDAV');
$server = new Sabre\DAV\Server(new Sabre\DAV\FS\Directory($publicDir));
$server->setBaseUri('/server.php'); // 设置你的基础URI,与本文件名一致
// 认证插件
$authPlugin = new Sabre\DAV\Auth\Plugin($authBackend);
$server->addPlugin($authPlugin);
/* 支持LOCK和UNLOCK */
$lockBackend = new Sabre\DAV\Locks\Backend\File('/tmp/locksdb');
$lockPlugin = new Sabre\DAV\Locks\Plugin($lockBackend);
$server->addPlugin($lockPlugin);
/* 支持浏览器插件 */
$browser = new Sabre\DAV\Browser\Plugin();
$server->addPlugin($browser);
$server->exec();
?>
同目录新建.htdigest文件,设置账号密码:
admin:SabreDAV:949ceab2f978c57f05bb221b095d4f29
//格式:账号:admin 密码:123456,
//生成工具
https://websistent.com/tools/htdigest-generator-tool///Realm:填SabreDAV
打开系统,添加网络位置:
DAV.rar(1.16 MB)完整代码:
DAV.rar(1.16 MB)
推荐使用rclone挂载webdav吧,没有太多限制性能更好
一加ace2Pro(灰|24+1024)