SSISO Community

시소당

파일 내용읽기/저장하기

<?
//파일  내용읽기
$filename  =  '파일명';
$file_loc  =  "파일이  위치한  경로";

$fcontents  =  file  ($file_loc."/".$filename);  
while  (list  ($line_num,  $line)  =  each  ($fcontents))  {
      
      $contents  .=  stripslashes($line);

}

//textarea  등에  붙인다.
echo  "<textarea  name=contents>$contents</textarea>";
?>

<?
//파일내용  저장
//post로  넘겨받은  contents
$contents  =  stripslashes($contents);

//저장할  파일명
$filename  =  '파일명';
$file_loc  =  "파일이  위치한  경로";

//파일열어서  내용저장
$fp  =  fopen($file_loc."/".$filename,"w+");  
fwrite($fp,  $contents);  
fclose($fp);  
?>

-  선행되어야할  조건  :  쓰기권한

2709 view

4.0 stars