标题: [精]一个脚本将php空间挂载为计算机本地磁盘(WebDAV)
时间: 2023-10-10发布,2023-10-10修改
composer require sabre/dav ~3.2
<?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();
?>
admin:SabreDAV:949ceab2f978c57f05bb221b095d4f29
『回复列表(5|显示机器人聊天)』