ファイルのコピー、削除、名前変更
filemanager_html.php コードを変更します:
<?php <!-- 循環(huán)輸出文件列表--> <?php foreach($file_list['file'] as $v): ?> <tr> <td><img src="./img/file.png"><?php echo $v['filename'];?></td> <td><?php echo $v['filemtime'];?></td> <td><?php echo $v['filesize'];?>KB</td> <td> <a href="?path=<?php echo $v['filepath'];?>&a=rename">重命名</a> <a href="?path=<?php echo $v['filepath'];?>&a=copy">復(fù)制</a> <a href="?path=<?php echo $v['filepath'];?>&a=del">刪除</a> </td> </tr> <?php endforeach;?>
filemanager.php コードを変更します:
<?php //獲取操作參數(shù) $action=isset($_GET['a'])?$_GET['a']:''; switch ($action){ //返回上一級目錄 case 'prev': $path=dirname($path); break; //其他操作... case 'copy': if($file){ if(file_exists("$path/$file.bak")){ die('文件名沖突,復(fù)制失敗'); } if(!copy("$path/$file","$path/$file.bak")){ die('復(fù)制文件失敗'); } } break; case 'del': if($file){ unlink("$path/$file"); } break; case 'rename': if(!empty($_POST)){ //獲取目標(biāo)文件名 $target=isset($_POST['target'])?trim($_POST['target']):''; //如果待操作文件不為空,則進行重命名操作 if($file && $target){ if(file_exists("$path/$target")){ die('目標(biāo)文件已經(jīng)存在'); } rename("$path/$file","$path/$target"); } //重命名完成后跳轉(zhuǎn) header('Localtion:?path='.$path); } break; }
名前の変更は ' に含める必要がありますreturn 上位ディレクトリにコードを追加して、新しいファイルの名前を変更します:
<?php <!--重命名操作區(qū)--> <?php if($action=='rename'):?> <form method="post"> 將<span><?php echo $file;?></span> 重命名為:<input type="text" value="<?php echo $file;?>" name="target" /> <input type="submit" value="確定"/> </form> <?php endif;?>
コピー効果の表示:
##ディスプレイの削除:
# ##################################