$act和$filename沒定義成功,提示Notice: Undefined index:
require_once 'dir.func.php';
require_once 'file.func.php';
require_once 'common.func.php';
$path="file";
$info=readDirectory($path);
$act= $_REQUEST['act'];
$filename=$_REQUEST['filename'];
if($act == "createFile"){
//創建文件
echo $_REQUEST['act'],"--";
echo $_REQUEST['filename'];
// $mes=createFile($path."/".$filename);
// alertMes($mes,$redirect);
}
?>
瀏覽器上顯示
Notice: Undefined index: act in?D:\WWW\fileManager\index.php?on line?8
Notice: Undefined index: filename in?D:\WWW\fileManager\index.php?on line?9
$act和$filename沒定義成功,這個是什么原因呀!有同學說?$_REQUEST前面加@就沒有提示了,但是我創建不了文件呀。。
2017-07-06
重命名只獲取到了重命名時的名字,沒有獲取到原來的filename
2017-05-02
Notice: Undefined index: act in D:\phpStudy\WWW\dongtai\everyany\shopimooc\admin\doAdminAction.php on line 4
Notice: Undefined variable: mes in D:\phpStudy\WWW\dongtai\everyany\shopimooc\admin\doAdminAction.php on line 22
2017-03-23
還是不行,求解!?。?lt;?php
header("Content-Type: text/html;charset=utf-8");
require_once 'dir.func.php';
require_once 'file.func.php';
require_once 'common.func.php';
$path = 'File';
$act = $_REQUEST['act'];
$filename = $_REQUEST['filename'];
$info = readDirectory($path);
$redirect = "index.php?path={$path}";
if ($act == "createFile") {
? ?//創建文件
? ?//echo $filename;
? ?//echo $path."--";
? ?$mes = createFile($path . "/" . $filename);
? ?alterMes($mes, $redirect);
} elseif ($act == "showContent") {
? ?$content = file_get_contents($filename);
? ?//echo "<textarea readonly='readonly' cols='100' rows='10'>{$content}</textarea>";
? ?if (strlen($content)) {
? ? ? ?highlight_string($content); ?//高亮顯示字符串中的PHP代碼
? ? ? ?// 高亮顯示文件中的PHP代碼 ?highlight_file($content)
? ?} else {
? ? ? ?alterMes("文件沒有內容,請編輯后再查看!", $redirect);
? ?}
} elseif ($act == "editContent") {
? ?//修改文件內容
? ?//獲取文件內容
? ?$content = file_get_contents($filename);
? ?$str = <<< EOF
? ? <form action = 'index.php?act = doEdit' method = 'post'>
? ? <textarea name = 'content' cols ='100' rows = '20'>{$content}</textarea></br>
? ? <input type='hidden' name='filename' value='{$filename}'/>
? ? <input type="hidden" name="path" value="{$path}" />
? ? <input type = 'submit' value = "修改文件內容"/>
? ? </form>
EOF;
? ?echo $str;
} elseif ($act == "doEdit") {
? ?//修改文件內容的操作
? ?$content = $_REQUEST('content');
? ?//echo $filename;exit;
? ?echo $content;
? ?if (file_put_contents($filename, $content)) {
? ? ? ?$mes = "文件修改成功";
? ?} else {
? ? ? ?$mes = "文件修改失敗";
? ?}
? ?alterMes($mes, $redirect);
} elseif ($act == "renameFile") {
? ?//完成重命名
? ?$str = <<<EOF
<form action="index.php?act=doRename" method ="post">
請填寫新文件名:<input type="text" name="newname" placeholder="重命名"/>
<input type='hidden' name='filename' value='{$filename}'/>
<input type="submit" value="重命名"/>
</form>
EOF;
? ?echo $str;
}elseif($act == "deRename"){
? ?//實現重命名的操作
? ?$newname = $_REQUEST['newname'];
? ?renameFile($filename,$newname);
}
?>
2016-01-28
我是小白,應該是表單那里沒有 ?name="filename" name="path"這兩個
2016-01-02
因為index.php在打開的的時候就會去執行代碼,顯然這兩個變量在未添加新文件的時候,是不存在的,所以分別做一個判斷就可以了,代碼如下【請看加粗部分】:
<?php
require_once 'dir.func.php';
require_once 'file.func.php';
require_once 'common.func.php';
$path="file";
$info=readDirectory($path);
// print_r($info);
if(isset($_REQUEST['act'])){
?? ?$act=$_REQUEST['act'];
}
if(isset($_REQUEST['filename'])){
?? ?$filename=$_REQUEST['filename'];
}
$redirect="index.php?path={$path}";
if(isset($act)){
?? ?if($act == "createFile"){
?? ??? ?$mes = createFile($path."/".$filename);
?? ??? ?alertMes($mes,$redirect);
?? ?}
}
2015-08-09
我也出現這樣的情況,現在還不不知道怎么辦。頂上去~
2015-05-16
這個比較簡單,你可以@壓制,或者重定義一下這些post,get或者request請求