fapchat
@fapchat

Почему не работает fopen?

//testfile.php
<?php // testfile.php
 $fh = fopen("testfile.txt", 'w') or die("Failed to create file");
 $text = <<<_END
Line 1
Line 2
Line 3
_END;
 fwrite($fh, $text) or die("Could not write to file");
 fclose($fh);
 echo "File 'testfile.txt' written successfully";
?>

//testfile.txt
tututu

If you receive an error message, your hard
disk may be full or, more likely, you may not have permission to create or write to the file, in which case you should modify the attributes of the destination folder accord‐
ing to your operating system. Otherwise, the file testfile.txt should now be residing in
the same folder in which you saved the testfile.php program.

Разрешение для папки у меня полное для всех, диск не полон, testfile.txt и testfile.php в одной папке

5d9f96ec667e5182954480.png
5d9f9747ba650953083393.png
  • Вопрос задан
  • 640 просмотров
Решения вопроса 1
@Alessandro2981
Скорее всего доступ на файл не хватает для write, попробуйте sudo chmod -R 777 testfile.txt
Ответ написан
Пригласить эксперта
Ответы на вопрос 1
VladimirAndreev
@VladimirAndreev
php web dev
А отображение ошибок включено? Или в логи посмотрите, там warning должно быть
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы