為什么點(diǎn)擊 新建按鈕沒(méi)有反應(yīng)
<?php
$path="file";
$act=$_REQUEST['act'];
$filename=$_REQUEST['filename'];
$info=readDirectory($path);
//print_r($info);
$redirect="index.php?path={$path}";
if($act=="createFile"){
? ? $mes=createFile($path."/".$filename);
? ? alertMes($mes,$redirect);
}
function createFile($filename){
? ? //驗(yàn)證文件的合法性是否包含/,*,<>,?,|
? ? $pattern="/[\/,\*,<>,\?\|]/";
? ? if (!preg_match($pattern,basename($filename))){
? ? ? ? //檢測(cè)當(dāng)前目錄下是否存在同名文件
? ? ? ? if (!file_exists($filename)){
? ? ? ? ? ? //通過(guò)touch($filename)來(lái)創(chuàng)建
? ? ? ? ? ? if (touch($filename)){
? ? ? ? ? ? ? ? return "文件創(chuàng)建成功!";
? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? ? ? return " 文件創(chuàng)建失??!";
? ? ? ? ? ? ? ? }
? ? ? ? }else {
? ? ? ? ? ? return "文件已存在,請(qǐng)重命名后創(chuàng)建!";
? ? ? ? }
? ? }else {
? ? ? ? return "非法文件名";
? ? }
? ? }
function alertMes($mes,$url) {
? ? echo "<script type='text/javascript'> alert('{$mes}');location.href='{$url}'; ?</script> ";
}
<td>請(qǐng)輸入文件名稱</td>
<td><input type="text" name="filename" />
<input type="hidden" name="path" value="<?php echo $path?>" />
<input type="hidden" name="act" value="createFile" />
<input type="submit" value="創(chuàng)建文件" />
</td>
2017-02-20
<form action="index.php" method="psot" enctype="multipart/form-data">
...........
</form>
2017-02-20
表單form你都沒(méi)有寫(xiě)