PHP로 파일 관리자를 만들었습니다. 모두 잘 읽고, 삭제, 이동, 편집하고 있습니다. 그러나 수정할 파일의 내용을 표시 할 때 문제가 있습니다.PHP : 파일 편집 용 양식
<?php
if (isset($_POST['file'])) {
$file = $_POST['file'];
?>
<form action="edit_file_process3.php" method="get">
<p>This is the content of the file <?php echo $file; ?>. Now you can modify it:</p>
<textarea rows="10" cols="70" name="content"><?php readfile($file) ?></textarea>
<p><input type="submit" name="submit" value="edit <?php echo $file; ?>" /> </p>
</form>
<a href="read2.php">Come back to the file manager</a>
처음 : 나는 텍스트 영역에서이 코드의 내용을 내가 파일 이름을 얻을 다른 페이지에서, 수정하고, 보여주기 위해 어떤 파일을 선택하는 사용자에게 떠나 이전의 형태에서
내가 파일을 선택하는 대신 적절한 내용의 텍스트 영역에서, 그것은 다음과 같이 나타납니다
<br />
<font size='1'><table class='xdebug-error xe-warning xe-scream' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>(!)</span> SCREAM: Error suppression ignored for</th></tr>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>(!)</span> Warning: readfile(prova4.txt): failed to open stream: No such file or directory in C:\wamp\www\LEARNING\Files\edit_file_process3.php on line <i>50</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0004</td><td bgcolor='#eeeeec' align='right'>144848</td><td bgcolor='#eeeeec'>{main}()</td><td title='C:\wamp\www\LEARNING\Files\edit_file_process3.php' bgcolor='#eeeeec'>..\edit_file_process3.php<b>:</b>0</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>2</td><td bgcolor='#eeeeec' align='center'>0.0004</td><td bgcolor='#eeeeec' align='right'>145248</td><td bgcolor='#eeeeec'><a href='http://www.php.net/readfile' target='_new'>readfile</a>
()</td><td title='C:\wamp\www\LEARNING\Files\edit_file_process3.php' bgcolor='#eeeeec'>..\edit_file_process3.php<b>:</b>50</td></tr>
</table></font>
나는 그것이 작동 후 뭔가 다른, 다음 시간이 텍스트를 덮어 쓸 경우 텍스트 영역은 적절한 내용을 표시합니다 파일에 대해. 처음에는이 작업을 수행한다는 것은 상당히 불쾌합니다. 왜 이런 일이 발생합니까?
readfile() 대신 file_get_contents() 및 file_put_contents() 함수를 사용해야합니다. readfile()은 파일을 읽고 echo ('file contents')처럼 출력 버퍼에 직접 씁니다. –
오류는 'prova4.txt'파일의 경로가 잘못되었음을 나타냅니다. – budwiser
나는 시도했다. with file_get_contents() 와 echo file_get_contents() 그러나 나는 동일한 오류가 발생했습니다. – johnnyfittizio