作者:陳業貴 華為雲享專家 51cto(專家部落客 明日之星 TOP紅人) 阿裡雲專家部落客
文章目錄
- index.php
- change.php
- 之前的
- 之後的:
代碼
index.php
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form action="change.php" method="POST">
您要增加檔案的絕對路徑: <input type="text" name="path" id="">
您要增加什麼檔案呢?<input type="text" name="file" id="">
<input type="submit" value="送出">
</form>
</body>
</html>
change.php
<?php
$path=$_POST['path'];//要建立檔案地方.某個目錄下我這裡是D:/phpstudy_pro/WWW/cyg/
$myfile = fopen($path.$_POST['file'],"w");//w可以往檔案裡面寫東西
$txt = "Bill Gates\n";//寫入這個變量中的資料。在666.txt檔案中
fwrite($myfile, $txt);
fclose($myfile);//關閉檔案
print_r($myfile);//運作檔案
之前的
之後的:
自己輸入的:
注意