2011-08-25 6 views
0

"readme.txt"찾을 수 없습니다. iPhone과 Android에서 Phonegap 예제가 작동하지 않습니다.로컬 파일 경로를 찾을 수 없습니다. Phonegap

 

       document.addEventListener("deviceready", onDeviceReady, false); 

      function onDeviceReady() { 
       window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail); 
      } 
      function gotFS(fileSystem) { 
       fileSystem.root.getFile("readme.txt", null, gotFileEntry, fail); 
      } 

      function gotFileEntry(fileEntry) { 
       console.log(evt.target.error.code); 

      } 


      function fail(evt) { 

       console.log(evt.target.error.code); 
      } 

+0

처럼 getFile() 기능에 패키지에서 경로를 추출 할 수 없습니다. 대신 상대 경로를 사용하여 파일을 읽을 수 있습니다. (발견되지 않으면 생성) –

답변

0

응용 프로그램의 문서 폴더에서만 파일을 가져올 수 있습니다.

파일은 {작성 : TRUE}와 '널'로 대체하여 만들 수 있습니다 발견되지 않으면 우리가 WWW 폴더에있는 모든 파일을 추가 할 때의 부분이 너무

<script type="text/javascript" charset="utf-8"> 
     document.addEventListener("deviceready", onDeviceReady, false); 

     function onDeviceReady() { 
      window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail); 
     } 

     function gotFS(fileSystem) { 
      fileSystem.root.getFile("readme.txt", {create: true}, gotFileEntry, fail); 
     } 

     function gotFileEntry(fileEntry) { 
      console.log("gotFileEntry"); 
     } 

     function fail(evt) { 
      console.log("Error : "+evt.code); 
     } 
    </script> 
관련 문제