자바 스크립트를 사용하여 HTML 파일과 동일한 디렉토리에있는 텍스트 파일을 읽으 려하므로 HTML 파일에 텍스트 파일의 내용이 포함될 수 있습니다. 파일. 여기 자바 스크립트 예제가 중요 사이트에서 발견되어 작동하지 않습니다.
내가 document.write를 여전히 아무것도와 '쓰기'를 대체하려고했습니다<html>
<head>
</head>
<body>
<script>
fh = fopen('my.txt', 0); // Open the file for reading.
if(fh!=-1) // Check if the file has been successfully opened.
{
length = flength(fh); // Get the length of the file.
str = fread(fh, length); // Read in the entire file.
fclose(fh); // Close the file.
// Display the contents of the file.
write(str);
}
</script>
</body>
</html>
는 fopen과 FREAD 기능을 테스트해야하는 코드입니다. 여기
예로 들어이 코드를 가지고 일부 웹 사이트입니다http://answers.yahoo.com/question/index?qid=20130519190823AA2lQ1W
http://www.c-point.com/JavaScript/articles/file_access_with_JavaScript.htm
전혀 어떤 도움이 많이 주시면 감사하겠습니다.
감사합니다 !!!
귀하가 선택한 코드 스 니펫은 Javascript가 아닙니다. 이 예제는 작동하지 않으며 Yahoo! 사이트는 잘못되었습니다. PHP에서이 작업을 수행 할 수 있습니다. 또는 AJAX 호출을 사용하는 경우 Javascript로 수행 할 수 있습니다. –