編輯完成後,提交內容時,需要把原來的文件路徑也提交,
然後服務端直接file_put_contents(文件名,文件內容,true); 就可以了。
然後服務端直接file_put_contents(文件名,文件內容,true); 就可以了。
解决方案 »
- 为什么不满足条件 还是进入if 输出了用户名格式错误QAQ
- 搭建nginx+PHP环境后访问php网页nginx.exe报错
- 求用js写的列表滚动条(用键盘方向键控制光标上下移动)
- PHP防作弊验证码
- php中时间计算
- 为什么现在中文网站一般用gd2312而不是utf-8?
- 流量统计的一个问题
- 网页里面有分页符吗?
- 如何用php将表单提交给另一台服务器上的asp程序处理??
- 一段中英文混合的文字,如何正确的截断?
- thinkphp 使用 jquery 的异步,返回结果总是提示下载文件,郁闷了,不知道哪儿写错了,求解答
- 关于dedecms的问题,runphp="yes"相关,懂的大侠们请进...
index.php<?php
$file = isset($_REQUEST['file'])? $_REQUEST['file'] : '';if($file=='' || file_exists($file)==false){
echo 'file not exists';
exit();
}$content = isset($_POST['content'])? $_POST['content'] : '';if($content!=''){ // 有修改
file_put_contents($file, $content, true);
}?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title> New Document </title>
</head> <body>
<form name="form1" action="" method="post">
<p>文件內容</p>
<p><textarea name="content" style="width:500px;height:300px;"><?php echo file_get_contents($file); ?></textarea></p>
<p><input type="submit" name="b1" value="修改"></p>
</form>
</body>
</html>