2013-07-02 185 views
2

我試圖從網址下載一個圖片,但是在ios中沒有成功,但是在android中成功完成了。從ios手機上下載url圖片

var url = "http://www.intelligrape.com/images/logo.png"; // image url 
try{ 
    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fs) { 
     var imagePath = fs.root.fullPath + "/logo.png"; // full file path 
     var fileTransfer = new FileTransfer(); 
     fileTransfer.download(url, imagePath, function (entry) { 
      alert(entry.fullPath); // entry is fileEntry object 
     }, function (error) { 
      alert("Some error"); 
     }); 
    }) 
}catch(e){ 
    alert(e); 
} 

我得到的錯誤LocalFileSystem未定義。我包括這個cordova2.5.0.js。

我的Config.xml如下。

<?xml version="1.0" encoding="UTF-8"?> 
<cordova> 
<preference name="KeyboardDisplayRequiresUserAction" value="true" /> 
<preference name="SuppressesIncrementalRendering" value="false" /> 
<preference name="UIWebViewBounce" value="true" /> 
<preference name="TopActivityIndicator" value="gray" /> 
<preference name="EnableLocation" value="false" /> 
<preference name="EnableViewportScale" value="false" /> 
<preference name="AutoHideSplashScreen" value="true" /> 
<preference name="ShowSplashScreenSpinner" value="true" /> 
<preference name="MediaPlaybackRequiresUserAction" value="false" /> 
<preference name="AllowInlineMediaPlayback" value="false" /> 
<preference name="OpenAllWhitelistURLsInWebView" value="false" /> 
<preference name="BackupWebStorage" value="cloud" /> 

<plugins> 
    <plugin name="Device" value="CDVDevice" /> 
    <plugin name="Logger" value="CDVLogger" /> 
    <plugin name="Compass" value="CDVLocation" /> 
    <plugin name="Accelerometer" value="CDVAccelerometer" /> 
    <plugin name="Camera" value="CDVCamera" /> 
    <plugin name="NetworkStatus" value="CDVConnection" /> 
    <plugin name="Contacts" value="CDVContacts" /> 
    <plugin name="Debug Console" value="CDVDebugConsole" /> 
    <plugin name="Echo" value="CDVEcho" /> 
    <plugin name="File" value="CDVFile" /> 
    <plugin name="FileTransfer" value="CDVFileTransfer" /> 
    <plugin name="Geolocation" value="CDVLocation" /> 
    <plugin name="Notification" value="CDVNotification" /> 
    <plugin name="Media" value="CDVSound" /> 
    <plugin name="Capture" value="CDVCapture" /> 
    <plugin name="SplashScreen" value="CDVSplashScreen" /> 
    <plugin name="Battery" value="CDVBattery" /> 
    <plugin name="Globalization" value="CDVGlobalization" /> 
    <plugin name="InAppBrowser" value="CDVInAppBrowser" /> 
    </plugins> 

    <access origin="*" /> 
</cordova> 

回答

0

包含cordova2.5.0.js文件之前的所有自定義js文件。你可能會在你的代碼後加入它