当前位置:Gxlcms > PHP教程 > php实现编辑和保存文件的方法

php实现编辑和保存文件的方法

时间:2021-07-01 10:21:17 帮助过:12人阅读

本文实例讲述了php实现编辑和保存文件的方法。分享给大家供大家参考。具体如下:

save_file.php:

  1. session_start();
  2. $handle = fopen($_POST['original_file_name'], "w");
  3. $text = $_POST['file_contents'];
  4. if(fwrite($handle, $text) == FALSE){
  5. $_SESSION['error'] = 'There was an error';
  6. }else{
  7. $_SESSION['error'] = 'File edited successfully';
  8. }
  9. fclose($handle);
  10. header("Location: ".$_POST['page']);
  11. ?>

read_file.php:

  1. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. Untitled Document

希望本文所述对大家的php程序设计有所帮助。

保存文件, php

人气教程排行