2010-12-11 68 views

回答

0

您的phonegap項目中的www文件夾是根。因此,例如,該文件夾中一個image.png中加入

<img src="image.png" /> 
0

我參考保存在文檔中的圖像文件夾是這樣的:在/ var /移動/應用/ 21F126D3-D345-490D-91C6-7619CC682944 /文檔/ 'name'.jpg

包含字母和數字的部分對於每個應用都是單獨的,因此您的將會有所不同。你可以得到這個:

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSys) { 
    var pathToRoot = fileSys.root.fullPath; 
}, function() { 
    console.log('****iPhone:Error when requesting persisten filesystem to find root path.'); 
}); 

這在phonegap docs解釋。

2
getAbsolutePath("mead.jpg", 
         function(entry){ 
          //alert(entry.fullPath); 
          $("#img_test").attr("src",entry.fullPath); 
          console.log("jq$:=" + entry.fullPath); 
          //$("#img_test").attr("src","img/test.jpg"); 
         }); 

// file system 
    function getAbsolutePath(file_name,call_back){ 
     var full_path = ""; 
     window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, 
       function (file_system){ 
        file_system.root.getFile(
         file_name, 
         {create: false}, 
         call_back 
         , 
         function(){ 
          console.log("failed to fetch file, please check the name"); 
         } 
        ); 

       }, 
       function(){ 
        console.log("failed file sytem"); 
       } 
     ); 


    } 
相關問題