나는 PHP를 배우고 fopen()
함수를 사용하려고합니다. 코딩중인 php 파일은이 디렉토리에 있습니다. /domains/xxxxx.com.au/public_html/phpfile.php
열려는 파일의 경로를 지정해야합니다. 예를 들어,이 파일 경로가있는 PC의 서버를 기반으로합니다. $filename = "c:/newfile.txt";
온라인 서버가 아닙니다. .php fopen()을 올바르게 사용하는 방법
업데이트!
이것은 전체 스크립트입니다. 파일 위치가 정확합니다. 이제는 the4 스크립트가 "파일을 만들 수 없습니다"라고 반환합니다.이 파일의 폴더 위치에 대한 사용 권한과 관련이 있습니까? 이미있는 경우
가$fp = fopen("/domains/xxxxx.com.au/public_html/newfile.txt", "rt");
이가 열립니다 : 전체 경로를 제공
$fp = fopen("newfile.txt", "rt");
을 또는 :
<?php
$filename = "/domains/xxxxxxxx.com.au/public_html/newfile.txt";
$newfile = @fopen($filename, "w+") or die ("couldnt create the file");
fclose($newfile);
$msg = "<p>File Created</p>";
?>
<HTML>
<HEAD>
</HEAD>
<BODY>
<? echo "$msg" ?>
</BODY>
</HTML>
나는 이해할 수 없다. 온라인 서버에서 로컬 PC의 텍스트 파일을 열려고합니까? –
온라인 서버에서 파일 경로를 포맷하는 방법을 모른다. 예 : 그것은 "public_html/phpfile.php"또는 "/domains/xxxxx.com.au/public_html/phpfile.php"입니까 – Jacksta
열려는 파일의 실제 예제를 제공하지 않으시겠습니까? –