简单在线文件系统管理
文件的遍历,我还没写完找时间写
onlineeditor.php文件代码filepath = $filepath;
}
//当本类销毁的时候进行的操作
function __destruct(){
// echo $this->filepath;
}
//获取文件的内容
function getcontent($filepath){
if (!isset($filepath)) {
} else{
//获取文件内容
$filecontent = file_get_contents($filepath);
return $filecontent;
}
}
//放入文件内容
function putcontent($filepath,$filecontent){
file_put_contents($filepath, $filecontent);
}
//判断目录是否存在
private function judgeexist(){
//判断目录是否为空或者没有文件
if(is_dir($this->filepath) && file_exists($this->filepath)){
return true;
} else{
return false;
}
}
//创建文件
function createfile($filename){
if(!file_exists($filename)){
fopen($filename, w+);
}
else{
echo 点此返回;
die(文件已经存在);
}
}
//删除文件
function delfile($filename){
if(file_exists($filename)){
unlink($filename);
}
}
//主函数
function main(){
if($this->judgeexist()){
//获取打开文件夹对象
$fileopen = opendir($this->filepath);
$filemes = array();
$i = 0;
//遍历文件夹
while ($file = readdir($fileopen)) {
//过滤
if(in_array($file, $this->filefilter)){
continue;
}
$filemespush = array(
'filecode' => $i,
'filename' => $file,
'filetype' => filetype($file),
'filesize' => filesize($file),
'filemtime' => filemtime($file)
);
array_push($filemes, $filemespush);
$i++;
}
//关闭文件
return $filemes;
fclose($fileopen);
} else{
die(不存在此文件夹);
}
}
}
?>index.phpmain();
//处理文件路径
function subfilepath($dirpath,$filename){
// echo $dirpath . $filename;
return $dirpath . $filename;
}
//初始化
if(array_key_exists('action', $_get)){
switch ($_get['action']) {
case 'updata':
$action = 'updata';
break;
case 'del':
$onlineeditor->delfile(subfilepath($dirpath,$_get['filename']));
$action = 'del';
echo subfilepath($dirpath,$_get['filename']);
echo ;
break;
}
} else{
$action = null;
}
if(array_key_exists('action', $_post)){
switch ($_post['action']) {
case 'create':
$onlineeditor->createfile(subfilepath($dirpath,$_post['filename']));
echo ;
break;
}
}
//获取文件内容
if(array_key_exists('filename', $_get) && $_get['action'] == 'updata'){
$root = subfilepath($dirpath,$_get['filename']);
$filecontent = $onlineeditor -> getcontent($root);
} else
$filecontent = 坚持就是胜利;
if (array_key_exists('filecontent', $_post)) {
// var_dump($_post);
$onlineeditor->putcontent(subfilepath($dirpath,$_post['filename']),$_post['filecontent']);
echo ;
}
//引入界面
require ./vieweditor.html;
// print_r($filemes);
?>vieweditor.php
在线文件编辑器
文件在线管理
name=filename />
序号文件名文件类型文件大小创建日期其他操作
>修改
>删除
内容杂,详情请下载代码。
简单的文件在线管理.zip ( 4.36 kb 下载:144 次 )
ad:真正免费,域名+虚机+企业邮箱=0元